home *** CD-ROM | disk | FTP | other *** search
/ Champak 114 / Vol 114.iso / games / pico_2.swf / scripts / frame_5 / DoAction.as
Encoding:
Text File  |  2010-08-12  |  88.5 KB  |  3,162 lines

  1. function resetAll()
  2. {
  3.    _root.gamesup = false;
  4.    _root.aiclose = false;
  5.    _root.iknowit = false;
  6.    stopAllSounds();
  7.    delete this.onEnterFrame;
  8.    _root.g.unloadMovie();
  9.    _root.g.removeMovieClip();
  10.    _root.water.unloadMovie();
  11.    _root.water.removeMovieClip();
  12.    _root.dudes.unloadMovie();
  13.    _root.dudes.removeMovieClip();
  14.    _root.pw.unloadMovie();
  15.    _root.pw.removeMovieClip();
  16.    _root.cover.unloadMovie();
  17.    _root.cover.removeMovieClip();
  18.    _root.hud.unloadMovie();
  19.    _root.hud.removeMovieClip();
  20.    _root.bg.unloadMovie();
  21.    _root.bg.removeMovieClip();
  22.    _root.gameover.unloadMovie();
  23.    _root.gameover.removeMovieClip();
  24.    _root.gotoAndStop(3);
  25. }
  26. function chkAchieve(vin)
  27. {
  28.    stopAllSounds();
  29.    h = _root.attachMovie("gameover","gameover",888);
  30.    var _loc2_ = false;
  31.    if(vin == "good")
  32.    {
  33.       _root.fanfaresound.start();
  34.       h.picos._visible = true;
  35.       h.ubers._visible = false;
  36.       if(aion)
  37.       {
  38.          _root.so.data.onepwins += 1;
  39.       }
  40.       if(!_root.aion)
  41.       {
  42.          _root.so.data.twopwins += 1;
  43.       }
  44.       if(team0.length == 1 && team1.length == 3 && !_root.so.data.onepthreeonone && aion)
  45.       {
  46.          _root.so.data.onepthreeonone = true;
  47.          _loc2_ = true;
  48.       }
  49.       if(team0.length == 2 && team1.length == 6 && !_root.so.data.onepsixontwo && aion)
  50.       {
  51.          _root.so.data.onepsixontwo = true;
  52.          _loc2_ = true;
  53.       }
  54.       if(team0.length == 1 && team1.length == 6 && aion)
  55.       {
  56.          _root.so.data.onepsixonone += 1;
  57.          if(_root.so.data.onepsixonone == 3)
  58.          {
  59.             _loc2_ = true;
  60.          }
  61.       }
  62.       if(_root.abletomove == false && aion)
  63.       {
  64.          _root.so.data.onepart += 1;
  65.          if(_root.so.data.onepart == 1 || _root.so.data.onepart == 5)
  66.          {
  67.             _loc2_ = true;
  68.          }
  69.       }
  70.       if(_root.cavern && !_root.so.data.onepcav)
  71.       {
  72.          _root.so.data.onepcav = true;
  73.          _loc2_ = true;
  74.       }
  75.       if(_root.abletoswitch == false && aion)
  76.       {
  77.          _root.so.data.onepnoswitch += 1;
  78.          if(_root.so.data.onepnoswitch == 2)
  79.          {
  80.             _loc2_ = true;
  81.          }
  82.       }
  83.       if(!_root.so.data.onepgrenades && goodweaps[0] == 0 && goodweaps[2] == 0 && goodweaps[3] == 0 && goodweaps[4] == 0 && goodweaps[5] == 0 && aion)
  84.       {
  85.          _root.so.data.onepgrenades = true;
  86.          _loc2_ = true;
  87.       }
  88.    }
  89.    else
  90.    {
  91.       losesound.start();
  92.       h.picos._visible = false;
  93.       h.ubers._visible = true;
  94.       _root.so.data.losses += 1;
  95.    }
  96.    _root.tot1ploss = _root.so.data.losses;
  97.    _root.tot1pwins = _root.so.data.onepwins;
  98.    var _loc4_ = 0;
  99.    i = 0;
  100.    while(i < _root.so.data.bgplays.length)
  101.    {
  102.       if(i == _root.bgid)
  103.       {
  104.          _root.so.data.bgplays[i] += 1;
  105.       }
  106.       if(_root.so.data.bgplays[i] > 0)
  107.       {
  108.          _loc4_ += 1;
  109.       }
  110.       i++;
  111.    }
  112.    if(_loc4_ >= _root.so.data.bgplays.length && !_root.so.data.bggotten)
  113.    {
  114.       _loc2_ = true;
  115.       _root.so.data.bggotten = true;
  116.    }
  117.    var _loc3_ = 0;
  118.    i = 0;
  119.    while(i < _root.so.data.fgplays.length)
  120.    {
  121.       if(i == _root.fgid)
  122.       {
  123.          _root.so.data.fgplays[i] += 1;
  124.       }
  125.       if(_root.so.data.fgplays[i] > 0)
  126.       {
  127.          _loc3_ += 1;
  128.       }
  129.       i++;
  130.    }
  131.    if(_loc3_ >= _root.so.data.fgplays.length && !_root.so.data.fggotten)
  132.    {
  133.       _loc2_ = true;
  134.       _root.so.data.fggotten = true;
  135.    }
  136.    if(_loc2_)
  137.    {
  138.       h.adv._visible = true;
  139.    }
  140.    else
  141.    {
  142.       h.adv._visible = false;
  143.    }
  144. }
  145. function clearTel()
  146. {
  147.    _root.panon = false;
  148.    _root.airstrike = false;
  149.    _root.teleportation = false;
  150.    _root.teletubby.unloadMovie();
  151.    _root.teletubby.removeMovieClip();
  152. }
  153. function flashIt()
  154. {
  155.    this.attachMovie("flashthing","flashit",9999);
  156. }
  157. function chkTel()
  158. {
  159.    if(_root.sel.Yvel < 1.5)
  160.    {
  161.       _root.clearTel();
  162.       _root.readytoswitchweapons = false;
  163.       _root.teletimer += 1;
  164.       if(_root.teletimer > 10)
  165.       {
  166.          _root.turncv = 1;
  167.          clearInterval(_root.teltimer);
  168.       }
  169.    }
  170. }
  171. function freshInst(mod, who)
  172. {
  173.    k = hud.createEmptyMovieClip("inst",199);
  174.    if(mod == 0)
  175.    {
  176.       i = 0;
  177.       while(i < 2)
  178.       {
  179.          w = k.attachMovie("invblock","block" + i,i);
  180.          w._x = w._width * i;
  181.          if(i == 0)
  182.          {
  183.             w.holder.attachMovie("icon_switch","guts",0);
  184.             w.nam = "\'S\'";
  185.          }
  186.          if(i == 1)
  187.          {
  188.             w.holder.attachMovie("icon_check","guts",0);
  189.             w.nam = "SPACE";
  190.          }
  191.          w.amt._visible = false;
  192.          i++;
  193.       }
  194.    }
  195.    if(mod == 1)
  196.    {
  197.       i = 0;
  198.       while(i < 2)
  199.       {
  200.          w = k.attachMovie("invblock","block" + i,i);
  201.          w._x = w._width * i;
  202.          if(i == 0)
  203.          {
  204.             w.holder.attachMovie("icon_leftright","guts",0);
  205.             w.nam = "ARROWS";
  206.          }
  207.          if(i == 1)
  208.          {
  209.             w.holder.attachMovie("icon_aim","guts",0);
  210.             w.nam = "SPACE";
  211.          }
  212.          w.amt._visible = false;
  213.          i++;
  214.       }
  215.    }
  216.    if(mod == 2)
  217.    {
  218.       offsetx = 0;
  219.       i = 0;
  220.       while(i < who.myweaps.length + 1)
  221.       {
  222.          w = k.attachMovie("invblock","block" + i,i);
  223.          w._x = w._width * i - offsetx * w._width;
  224.          if(who.myweaps[i] != -1)
  225.          {
  226.             if(who.myweaps[i] > 0 || i >= who.myweaps.length)
  227.             {
  228.                if(i < who.myweaps.length)
  229.                {
  230.                   w.nam = i + 1;
  231.                   w.holder.attachMovie("item" + i,"guts",0);
  232.                   w.amt.amt = who.myweaps[i];
  233.                   w.amt.inf._visible = false;
  234.                }
  235.                else
  236.                {
  237.                   w.holder.attachMovie("icon_esc","guts",0);
  238.                   w.amt._visible = false;
  239.                   w.nam = "\'ESC\'";
  240.                }
  241.             }
  242.             else
  243.             {
  244.                w._visible = false;
  245.                offsetx += 1;
  246.             }
  247.          }
  248.          else
  249.          {
  250.             w.nam = i + 1;
  251.             w.holder.attachMovie("item" + i,"guts",0);
  252.             w.amt.inf._visible = true;
  253.             w.amt.amt = "";
  254.          }
  255.          i++;
  256.       }
  257.    }
  258.    if(mod == 3)
  259.    {
  260.       i = 0;
  261.       while(i < 2)
  262.       {
  263.          w = k.attachMovie("invblock","block" + i,i);
  264.          w._x = w._width * i;
  265.          if(i == 0)
  266.          {
  267.             w.holder.attachMovie("icon_updown","guts",0);
  268.             w.nam = "ARROWS";
  269.          }
  270.          if(i == 1)
  271.          {
  272.             w.holder.attachMovie("icon_power","guts",0);
  273.             w.nam = "SPACE";
  274.          }
  275.          w.amt._visible = false;
  276.          i++;
  277.       }
  278.    }
  279.    if(mod == 4)
  280.    {
  281.       i = 0;
  282.       while(i < 1)
  283.       {
  284.          w = k.attachMovie("invblock","block" + i,i);
  285.          w._x = w._width * i;
  286.          if(i == 0)
  287.          {
  288.             w.holder.attachMovie("icon_go","guts",0);
  289.             w.nam = "SPACE";
  290.          }
  291.          w.amt._visible = false;
  292.          i++;
  293.       }
  294.    }
  295.    if(mod == 5)
  296.    {
  297.       i = 0;
  298.       while(i < 2)
  299.       {
  300.          w = k.attachMovie("invblock","block" + i,i);
  301.          w._x = w._width * i;
  302.          if(i == 0)
  303.          {
  304.             w.holder.attachMovie("icon_leftright","guts",0);
  305.             w.nam = "ARROWS";
  306.          }
  307.          if(i == 1)
  308.          {
  309.             w.holder.attachMovie("icon_go","guts",0);
  310.             w.nam = "SPACE";
  311.          }
  312.          w.amt._visible = false;
  313.          i++;
  314.       }
  315.    }
  316.    k._y = -520;
  317.    k.goal = -420;
  318.    k._x = 350 - k._width / 2;
  319.    k.onEnterFrame = function()
  320.    {
  321.       if(!_root.loadinglevel)
  322.       {
  323.          var _loc3_ = this.goal - this._y;
  324.          this._y += _loc3_ / 3;
  325.          var _loc4_ = Math.abs(_loc3_);
  326.          if(_loc4_ <= 1)
  327.          {
  328.             this._y = this.goal;
  329.             delete this.onEnterFrame;
  330.          }
  331.       }
  332.    };
  333. }
  334. function clearInst()
  335. {
  336.    hud.inst.onEnterFrame = function()
  337.    {
  338.       var _loc2_ = -550 - this._y;
  339.       this._y += _loc2_ / 4;
  340.       var _loc3_ = Math.abs(_loc2_);
  341.       if(_loc3_ <= 1)
  342.       {
  343.          this._y += _loc2_;
  344.          delete this.onEnterFrame;
  345.       }
  346.    };
  347. }
  348. function initLvl(bgcol, fgcol, inside, fgtex, bgtex)
  349. {
  350.    circcount = 0;
  351.    panspeed = 10;
  352.    _root.grav = 0.5;
  353.    b = _root.createEmptyMovieClip("g",1);
  354.    mainmusic = new Sound(b);
  355.    _root.curtrack = random(3);
  356.    mainmusic.attachSound("bgmusic" + _root.curtrack);
  357.    w = _root.attachMovie("waterclip","water",98);
  358.    w._y = 470;
  359.    _root.createEmptyMovieClip("dudes",4);
  360.    _root.createEmptyMovieClip("pw",2);
  361.    c = _root.createEmptyMovieClip("cover",3);
  362.    c.beginFill(bgcol,100);
  363.    c.moveTo(-600,-600);
  364.    c.lineTo(3500,-600);
  365.    c.lineTo(3500,3500);
  366.    c.lineTo(-600,3500);
  367.    c.endFill();
  368.    backy = c.attachMovie("bg" + bgtex,"bg",0);
  369.    cover.setMask(pw);
  370.    _root.attachMovie("HUD","hud",99);
  371.    hud._y = 426;
  372.    updateHUDdudes(team0.length,0);
  373.    updateHUDdudes(team1.length,1);
  374.    e = _root.createEmptyMovieClip("bg",0);
  375.    e.beginFill(bgcol,100);
  376.    e.lineTo(700,0);
  377.    e.lineTo(700,550);
  378.    e.lineTo(0,550);
  379.    e.endFill();
  380.    e.attachMovie("bg" + bgtex,"bg",0);
  381.    var _loc3_ = random(100) - 200;
  382.    var _loc2_ = random(200) + 400;
  383.    var _loc12_ = random(100) + 200;
  384.    var _loc11_ = random(550);
  385.    var _loc5_ = _loc3_ + random(150) + 400;
  386.    var _loc10_ = _loc2_ - random(150) - 50;
  387.    var _loc14_ = random(100) + 400;
  388.    var _loc13_ = random(550);
  389.    var _loc4_ = _loc5_ + random(150) + 200;
  390.    var _loc31_ = random(550);
  391.    var _loc20_ = random(100) + 750;
  392.    var _loc18_ = random(550);
  393.    var _loc9_ = _loc4_ + random(250) + 550;
  394.    var _loc30_ = random(350);
  395.    var _loc22_ = random(200) + 1350;
  396.    var _loc21_ = random(350);
  397.    var _loc8_ = _loc9_ + random(150) + 100;
  398.    var _loc29_ = random(550);
  399.    var _loc16_ = random(200) + 1700;
  400.    var _loc15_ = random(550);
  401.    var _loc7_ = _loc8_ + random(150) + 300;
  402.    var _loc27_ = random(550);
  403.    var _loc19_ = random(200) + 2200;
  404.    var _loc17_ = random(550);
  405.    var _loc6_ = _loc7_ + random(150) + 400;
  406.    var _loc24_ = random(550);
  407.    var _loc28_ = random(200) + 2700;
  408.    var _loc25_ = random(550);
  409.    var _loc26_ = _loc6_ + random(150) + 600;
  410.    var _loc23_ = random(550) + 300;
  411.    b.lineStyle(lineweight,0);
  412.    b.beginFill(fgcol,100);
  413.    b.moveTo(_loc3_,_loc2_);
  414.    b.curveTo(_loc12_,_loc11_,_loc5_,_loc10_);
  415.    b.curveTo(_loc14_,_loc13_,_loc4_,_loc31_);
  416.    b.curveTo(_loc20_,_loc18_,_loc9_,_loc30_);
  417.    b.curveTo(_loc22_,_loc21_,_loc8_,_loc29_);
  418.    b.curveTo(_loc16_,_loc15_,_loc7_,_loc27_);
  419.    b.curveTo(_loc19_,_loc17_,_loc6_,_loc24_);
  420.    b.curveTo(_loc28_,_loc25_,_loc26_,_loc23_);
  421.    b.curveTo(3800,1200,2000,1200);
  422.    b.curveTo(-100,1200,_loc3_,_loc2_);
  423.    b.endFill();
  424.    tx = b.createEmptyMovieClip("texture",2);
  425.    tx.beginFill(16777215,100);
  426.    tx.moveTo(_loc3_,_loc2_);
  427.    tx.curveTo(_loc12_,_loc11_,_loc5_,_loc10_);
  428.    tx.curveTo(_loc14_,_loc13_,_loc4_,_loc31_);
  429.    tx.curveTo(_loc20_,_loc18_,_loc9_,_loc30_);
  430.    tx.curveTo(_loc22_,_loc21_,_loc8_,_loc29_);
  431.    tx.curveTo(_loc16_,_loc15_,_loc7_,_loc27_);
  432.    tx.curveTo(_loc19_,_loc17_,_loc6_,_loc24_);
  433.    tx.curveTo(_loc28_,_loc25_,_loc26_,_loc23_);
  434.    tx.curveTo(3800,1200,2000,1200);
  435.    tx.curveTo(-100,1200,_loc3_,_loc2_);
  436.    tx.cacheAsBitmap = true;
  437.    ingrid = b.attachMovie("texture" + fgtex,"tex",1);
  438.    ingrid.setMask(tx);
  439.    if(inside)
  440.    {
  441.       _loc3_ = random(100) - 200;
  442.       _loc2_ = random(200) - 100;
  443.       _loc12_ = random(100) + 200;
  444.       _loc11_ = random(550) - 300;
  445.       _loc5_ = _loc3_ + random(150) + 400;
  446.       _loc10_ = _loc2_ - random(150) - 150;
  447.       _loc14_ = random(100) + 400;
  448.       _loc13_ = random(550) - 300;
  449.       _loc4_ = _loc5_ + random(150) + 200;
  450.       _loc31_ = random(750) - 400;
  451.       _loc20_ = random(100) + 750;
  452.       _loc18_ = random(550) - 300;
  453.       _loc9_ = _loc4_ + random(250) + 550;
  454.       _loc30_ = random(750) - 400;
  455.       _loc22_ = random(200) + 1350;
  456.       _loc21_ = random(350) - 300;
  457.       _loc8_ = _loc9_ + random(150) + 300;
  458.       _loc29_ = random(750) - 400;
  459.       _loc16_ = random(200) + 1700;
  460.       _loc15_ = random(550) - 300;
  461.       _loc7_ = _loc8_ + random(150) + 300;
  462.       _loc27_ = random(750) - 400;
  463.       _loc19_ = random(200) + 2200;
  464.       _loc17_ = random(550) - 300;
  465.       _loc6_ = _loc7_ + random(150) + 400;
  466.       _loc24_ = random(750) - 400;
  467.       _loc28_ = random(200) + 2700;
  468.       _loc25_ = random(550) - 300;
  469.       _loc26_ = _loc6_ + random(150) + 600;
  470.       _loc23_ = random(750) - 700;
  471.       r = b.createEmptyMovieClip("topp",-3);
  472.       r.lineStyle(lineweight,0);
  473.       r.beginFill(fgcol,100);
  474.       r.moveTo(_loc3_,_loc2_);
  475.       r.curveTo(_loc12_,_loc11_,_loc5_,_loc10_);
  476.       r.curveTo(_loc14_,_loc13_,_loc4_,_loc31_);
  477.       r.curveTo(_loc20_,_loc18_,_loc9_,_loc30_);
  478.       r.curveTo(_loc22_,_loc21_,_loc8_,_loc29_);
  479.       r.curveTo(_loc16_,_loc15_,_loc7_,_loc27_);
  480.       r.curveTo(_loc19_,_loc17_,_loc6_,_loc24_);
  481.       r.curveTo(_loc28_,_loc25_,_loc26_,_loc23_);
  482.       r.curveTo(3800,-1200,2500,-1900);
  483.       r.curveTo(-100,-1200,_loc3_,_loc2_);
  484.       tp = b.createEmptyMovieClip("texture2",-2);
  485.       tp.beginFill(fgcol,100);
  486.       tp.moveTo(_loc3_,_loc2_);
  487.       tp.curveTo(_loc12_,_loc11_,_loc5_,_loc10_);
  488.       tp.curveTo(_loc14_,_loc13_,_loc4_,_loc31_);
  489.       tp.curveTo(_loc20_,_loc18_,_loc9_,_loc30_);
  490.       tp.curveTo(_loc22_,_loc21_,_loc8_,_loc29_);
  491.       tp.curveTo(_loc16_,_loc15_,_loc7_,_loc27_);
  492.       tp.curveTo(_loc19_,_loc17_,_loc6_,_loc24_);
  493.       tp.curveTo(_loc28_,_loc25_,_loc26_,_loc23_);
  494.       tp.curveTo(3800,-1200,2500,-1900);
  495.       tp.curveTo(-100,-1200,_loc3_,_loc2_);
  496.       tp.endFill();
  497.       tp.cacheAsBitmap = true;
  498.       ingrid2 = b.attachMovie("texture" + fgtex,"tex2",-1);
  499.       ingrid2.setMask(tp);
  500.    }
  501.    b.cacheAsBitmap = true;
  502.    alignAll();
  503.    _root.attachMovie("levload","levload",9998281);
  504.    _root.physactive = true;
  505.    _root.loadinglevel = true;
  506.    _root.halfcv = 0;
  507.    _root.second = setInterval(half2,100);
  508. }
  509. function changeVol(main)
  510. {
  511.    main.slider._x = main._xmouse;
  512.    if(main.slider._x < main.thing._x + 10)
  513.    {
  514.       main.slider._x = main.thing._x + 10;
  515.    }
  516.    if(main.slider._x > main.thing._width + 10)
  517.    {
  518.       main.slider._x = main.thing._width + 10;
  519.    }
  520.    var _loc2_ = (main.slider._x - 24) / 28 * 100;
  521.    mainmusic.setVolume(_loc2_);
  522. }
  523. function switchTracks()
  524. {
  525.    if(_root.curtrack < 2)
  526.    {
  527.       _root.curtrack += 1;
  528.    }
  529.    else
  530.    {
  531.       _root.curtrack = 0;
  532.    }
  533.    mainmusic.stop();
  534.    mainmusic = new Sound(_root.g);
  535.    mainmusic.attachSound("bgmusic" + _root.curtrack);
  536.    mainmusic.start(0,999);
  537.    var _loc2_ = (hud.volcontrol.slider._x - 24) / 28 * 100;
  538.    mainmusic.setVolume(_loc2_);
  539. }
  540. function half2()
  541. {
  542.    halfcv += 1;
  543.    if(halfcv >= 3)
  544.    {
  545.       if(!_root.madeteam)
  546.       {
  547.          team0cv = 0;
  548.          team1cv = 0;
  549.          masterturn = "good";
  550.          updateHP();
  551.          makeTeam0();
  552.          makeTeam1();
  553.          _root.allvirts = setInterval(getVirts,5);
  554.          _root.g.cacheAsBitmap = true;
  555.          clearPointers();
  556.          showPointer();
  557.          _root.madeteam = true;
  558.       }
  559.       if(halfcv > 6 && !_root.chkout)
  560.       {
  561.          i = 0;
  562.          while(i < team0.length)
  563.          {
  564.             var yo = eval("dudes.good" + i);
  565.             var cv = 0;
  566.             while(r.hitTest(yo._x,yo._y,true) && cv < 900)
  567.             {
  568.                yo._y += 2;
  569.                yo.virty += 2;
  570.                yo._x += 0.5;
  571.                yo.virtx += 0.5;
  572.                cv += 1;
  573.             }
  574.             if(g.hitTest(yo.virtx,yo.virty - 15,true))
  575.             {
  576.                makeDivot(yo._x,yo._y + 10,random(200) + 100,yo);
  577.             }
  578.             i++;
  579.          }
  580.          i = 0;
  581.          while(i < team1.length)
  582.          {
  583.             var yo = eval("dudes.bad" + i);
  584.             var cv = 0;
  585.             while(r.hitTest(yo._x,yo._y,true) && cv < 900)
  586.             {
  587.                yo._y += 2;
  588.                yo.virty += 2;
  589.                yo._x += 0.5;
  590.                yo.virtx += 0.5;
  591.                cv += 1;
  592.             }
  593.             if(g.hitTest(yo.virtx,yo.virty - 15,true))
  594.             {
  595.                makeDivot(yo._x,yo._y + 10,random(200) + 100,yo);
  596.             }
  597.             i++;
  598.          }
  599.          _root.chkout = true;
  600.       }
  601.       if(halfcv > 18)
  602.       {
  603.          _root.levload.unloadMovie();
  604.          _root.levload.removeMovieClip();
  605.          _root.loadinglevel = false;
  606.          _root.selecting = true;
  607.          halfcv = 0;
  608.          _root.madeteam = false;
  609.          _root.chkout = false;
  610.          mainmusic.start(0,999);
  611.          mainmusic.setVolume(25);
  612.          clearInterval(_root.second);
  613.       }
  614.    }
  615. }
  616. function updateHP()
  617. {
  618.    var team0max = 0;
  619.    var team0total = 0;
  620.    var team0count = team0.length;
  621.    i = 0;
  622.    while(i < team0.length)
  623.    {
  624.       var d = eval("dudes.good" + i);
  625.       if(d.dead)
  626.       {
  627.          team0count -= 1;
  628.       }
  629.       team0max += parseInt(d.maxhp);
  630.       team0total += parseInt(d.hp);
  631.       i++;
  632.    }
  633.    hud.team0bar._xscale = team0total / _root.team0maxhp * 100;
  634.    var team1max = 0;
  635.    var team1total = 0;
  636.    var team1count = team1.length;
  637.    i = 0;
  638.    while(i < team1.length)
  639.    {
  640.       var d = eval("dudes.bad" + i);
  641.       if(d.dead)
  642.       {
  643.          team1count -= 1;
  644.       }
  645.       team1max += parseInt(d.maxhp);
  646.       team1total += parseInt(d.hp);
  647.       i++;
  648.    }
  649.    updateHUDdudes(team0count,0);
  650.    updateHUDdudes(team1count,1);
  651.    hud.team1bar._xscale = team1total / _root.team1maxhp * 100;
  652. }
  653. function updateHUDdudes(cv, which)
  654. {
  655.    i = 0;
  656.    while(i < 5)
  657.    {
  658.       if(which == 0)
  659.       {
  660.          var thing0 = eval("hud.g" + i);
  661.          thing0._visible = false;
  662.       }
  663.       else
  664.       {
  665.          var thing1 = eval("hud.d" + i);
  666.          thing1._visible = false;
  667.       }
  668.       i++;
  669.    }
  670.    i = 0;
  671.    while(i < cv)
  672.    {
  673.       if(which == 0)
  674.       {
  675.          var thing = eval("hud.g" + i);
  676.       }
  677.       else
  678.       {
  679.          var thing = eval("hud.d" + i);
  680.       }
  681.       thing._visible = true;
  682.       i++;
  683.    }
  684. }
  685. function getTurn(switcheroo)
  686. {
  687.    clearTel();
  688.    if(switcheroo)
  689.    {
  690.       clearInst();
  691.       var alldead = false;
  692.       var dfg = 0;
  693.       i = 0;
  694.       while(i < team1.length)
  695.       {
  696.          var turd = eval("dudes.bad" + i);
  697.          if(turd.dead)
  698.          {
  699.             dfg += 1;
  700.          }
  701.          i++;
  702.       }
  703.       if(dfg == team1.length)
  704.       {
  705.          alldead = true;
  706.       }
  707.       if(!alldead && aion)
  708.       {
  709.          _root.aiclose = false;
  710.          _root.iknowit = false;
  711.       }
  712.    }
  713.    _root.projtype = 1;
  714.    var beenswitched = false;
  715.    _root.beenreset = false;
  716.    offscreen.unloadMovie();
  717.    offscreen.removeMovieClip();
  718.    _root.team0maxhp = 0;
  719.    _root.team1maxhp = 0;
  720.    var dead0cv = team0.length;
  721.    var dead1cv = team1.length;
  722.    d = 0;
  723.    while(d < team0.length)
  724.    {
  725.       var w = eval("_root.dudes.good" + d);
  726.       w.bar._xscale = w._xscale;
  727.       w.bar.dabar._xscale = w.hp;
  728.       w.hittable = true;
  729.       if(!w.dead)
  730.       {
  731.          w.bar._visible = true;
  732.       }
  733.       else
  734.       {
  735.          dead0cv -= 1;
  736.          w.guts.gotoAndStop("dead");
  737.          w._xscale = 100;
  738.       }
  739.       _root.team0maxhp += parseInt(w.maxhp);
  740.       d++;
  741.    }
  742.    d = 0;
  743.    while(d < team1.length)
  744.    {
  745.       var w = eval("_root.dudes.bad" + d);
  746.       w.bar._xscale = w._xscale;
  747.       w.bar.dabar._xscale = w.hp;
  748.       w.hittable = true;
  749.       w.thinking._visible = false;
  750.       if(!w.dead)
  751.       {
  752.          w.bar._visible = true;
  753.       }
  754.       else
  755.       {
  756.          dead1cv -= 1;
  757.          w.guts.gotoAndStop("dead");
  758.          w._xscale = 100;
  759.       }
  760.       _root.team1maxhp += parseInt(w.maxhp);
  761.       d++;
  762.    }
  763.    updateHP();
  764.    if(dead0cv == 0 && dead1cv == 0)
  765.    {
  766.       trace("TIE!!!!");
  767.       hud.team0bar._xscale = 0;
  768.       hud.team1bar._xscale = 0;
  769.       var noloop = true;
  770.       var vinner = "good";
  771.    }
  772.    else
  773.    {
  774.       if(dead0cv == 0)
  775.       {
  776.          var vinner = "bad";
  777.          hud.team0bar._xscale = 0;
  778.          var noloop = true;
  779.       }
  780.       if(dead1cv == 0)
  781.       {
  782.          var vinner = "good";
  783.          hud.team1bar._xscale = 0;
  784.          var noloop = true;
  785.       }
  786.    }
  787.    if(switcheroo)
  788.    {
  789.       if(masterturn == "bad" && !beenswitched)
  790.       {
  791.          masterturn = "good";
  792.          beenswitched = true;
  793.       }
  794.       if(masterturn == "good" && !beenswitched)
  795.       {
  796.          masterturn = "bad";
  797.          beenswitched = true;
  798.       }
  799.    }
  800.    if(masterturn == "good")
  801.    {
  802.       team0cv += 1;
  803.       if(team0cv > team0.length - 1)
  804.       {
  805.          team0cv = 0;
  806.       }
  807.       var whobe = eval("dudes.good" + team0cv);
  808.    }
  809.    if(masterturn == "bad")
  810.    {
  811.       team1cv += 1;
  812.       if(team1cv > team1.length - 1)
  813.       {
  814.          team1cv = 0;
  815.       }
  816.       var whobe = eval("dudes.bad" + team1cv);
  817.    }
  818.    if(!noloop)
  819.    {
  820.       if(!aion || _root.masterturn == "good")
  821.       {
  822.          freshInst(0);
  823.       }
  824.       if(whobe.dead)
  825.       {
  826.          getTurn();
  827.       }
  828.       else
  829.       {
  830.          clearInterval(_root.waitforit);
  831.          clearInterval(_root.effectsWaiter);
  832.          _root.turncv = _root.maxturn;
  833.          _root.sel.guts.gotoAndStop("rest");
  834.          _root.retreatcv = 0;
  835.          _root.sel.retreating = false;
  836.          _root.waitforretreat = false;
  837.          _root.sel.aiming = false;
  838.          _root.waiting = false;
  839.          _root.physactive = false;
  840.          _root.sel = whobe;
  841.          _root.sel.retreating = false;
  842.          _root.sel.aiming = false;
  843.          clearPointers();
  844.          showPointer();
  845.          _root.selecting = true;
  846.          if(_root.aion)
  847.          {
  848.             if(masterturn == "bad")
  849.             {
  850.                _root.aiknown = false;
  851.             }
  852.          }
  853.       }
  854.    }
  855.    else
  856.    {
  857.       _root.gamesup = true;
  858.       _root.chkAchieve(vinner);
  859.    }
  860. }
  861. function showPointer()
  862. {
  863.    _root.sel.pointer._visible = true;
  864. }
  865. function clearPointers()
  866. {
  867.    d = 0;
  868.    while(d < team0.length)
  869.    {
  870.       var w = eval("_root.dudes.good" + d);
  871.       w.pointer._visible = false;
  872.       w.aimer._visible = false;
  873.       d++;
  874.    }
  875.    d = 0;
  876.    while(d < team1.length)
  877.    {
  878.       var w = eval("_root.dudes.bad" + d);
  879.       w.pointer._visible = false;
  880.       w.aimer._visible = false;
  881.       d++;
  882.    }
  883. }
  884. function getNormal(who)
  885. {
  886.    if(who.r == undefined)
  887.    {
  888.       if(who.ject)
  889.       {
  890.          who.r = who._height;
  891.       }
  892.       else
  893.       {
  894.          who.r = who._height / 2;
  895.       }
  896.       who.seg = 200;
  897.    }
  898.    var _loc4_ = 0;
  899.    who.xval = 0;
  900.    who.yval = 0;
  901.    i = 1;
  902.    while(i < who.seg)
  903.    {
  904.       var _loc3_ = who.virtx + who.r * Math.sin(i * (360 / who.seg) * 0.017453292519943295);
  905.       var _loc2_ = who.virty - who.r * Math.cos(i * (360 / who.seg) * 0.017453292519943295);
  906.       if(g.hitTest(_loc3_,_loc2_,true) && !cover.hitTest(_loc3_,_loc2_,true))
  907.       {
  908.          _loc4_ = _loc4_ + 1;
  909.          who.xval += _loc3_;
  910.          who.yval += _loc2_;
  911.       }
  912.       i++;
  913.    }
  914.    if(_loc4_ > 0)
  915.    {
  916.       who._rotation = Math.atan2(who.virtx - who.xval / _loc4_,who.virty - who.yval / _loc4_) / 0.017453292519943295 * -1 + 180;
  917.    }
  918. }
  919. function makeTeam0()
  920. {
  921.    _root.team0maxhp = 0;
  922.    h = 0;
  923.    while(h < team0.length)
  924.    {
  925.       d = dudes.attachMovie(team0[h],"good" + h,h);
  926.       d._x = random(2300) + 150;
  927.       d._y = 600;
  928.       d.hittable = true;
  929.       d.myweaps = new Array();
  930.       i = 0;
  931.       while(i < goodweaps.length)
  932.       {
  933.          d.myweaps[i] = goodweaps[i];
  934.          i++;
  935.       }
  936.       var _loc3_ = new Color(d.aimer.guts.col);
  937.       _loc3_.setRGB(9025731);
  938.       _loc3_ = new Color(d.pointer.col);
  939.       _loc3_.setRGB(9025731);
  940.       _loc3_ = new Color(d.bar.dabar);
  941.       _loc3_.setRGB(1208728);
  942.       d.id = h;
  943.       d.typ = "good";
  944.       d.Yvel = 0;
  945.       d.Xvel = 0;
  946.       while(g.hitTest(d._x,d._y,true))
  947.       {
  948.          d._y -= 0.2;
  949.       }
  950.       d.startcv = 0;
  951.       d.onEnterFrame = function()
  952.       {
  953.          phys(this);
  954.       };
  955.       d.speed = 2;
  956.       h++;
  957.    }
  958.    _root.sel = dudes.good0;
  959. }
  960. function makeTeam1()
  961. {
  962.    _root.team1maxhp = 0;
  963.    h = 0;
  964.    while(h < team1.length)
  965.    {
  966.       d = dudes.attachMovie(team1[h],"bad" + h,h + 100);
  967.       d._x = random(2300) + 150;
  968.       d._y = 600;
  969.       d.id = h;
  970.       d.thinking._visible = false;
  971.       d.hittable = true;
  972.       d.myweaps = new Array();
  973.       i = 0;
  974.       while(i < badweaps.length)
  975.       {
  976.          d.myweaps[i] = badweaps[i];
  977.          i++;
  978.       }
  979.       var _loc3_ = new Color(d.aimer.guts.col);
  980.       _loc3_.setRGB(16711680);
  981.       _loc3_ = new Color(d.pointer.col);
  982.       _loc3_.setRGB(16711680);
  983.       _loc3_ = new Color(d.bar.dabar);
  984.       _loc3_.setRGB(16711680);
  985.       d.typ = "bad";
  986.       d.Yvel = 0;
  987.       d.Xvel = 0;
  988.       while(g.hitTest(d._x,d._y,true))
  989.       {
  990.          d._y -= 0.2;
  991.       }
  992.       d.startcv = 0;
  993.       d.onEnterFrame = function()
  994.       {
  995.          phys(this);
  996.       };
  997.       h++;
  998.    }
  999. }
  1000. function getVirts()
  1001. {
  1002.    t = 0;
  1003.    while(t < team0.length)
  1004.    {
  1005.       var thing = eval("dudes.good" + t);
  1006.       thing.virtx = thing._x + g._x;
  1007.       thing.virty = thing._y + g._y;
  1008.       t++;
  1009.    }
  1010.    t = 0;
  1011.    while(t < team1.length)
  1012.    {
  1013.       var thing = eval("dudes.bad" + t);
  1014.       thing.virtx = thing._x + g._x;
  1015.       thing.virty = thing._y + g._y;
  1016.       t++;
  1017.    }
  1018.    alignAll();
  1019. }
  1020. function phys(who)
  1021. {
  1022.    if(!panon && !_root.firing)
  1023.    {
  1024.       if(_root.physactive || who.startcv < 2 || _root.sel == who)
  1025.       {
  1026.          who.bounced = false;
  1027.          who.mycurx = who._x;
  1028.          who.mycury = who._y;
  1029.          who.Yvel += _root.grav;
  1030.          who.storex = who._x;
  1031.          who.storey = who._y;
  1032.          who.storevirtx = who.virtx;
  1033.          who.storevirty = who.virty;
  1034.          var _loc3_ = 0;
  1035.          if(who.jumping)
  1036.          {
  1037.             var _loc4_ = - who._rotation;
  1038.             who._rotation += _loc4_ / 2;
  1039.          }
  1040.          while(g.hitTest(who.virtx,who.virty + who.Yvel / 2,true) && !cover.hitTest(who.virtx,who.virty + who.Yvel / 2,true) && !who.bounced)
  1041.          {
  1042.             who._y -= 1;
  1043.             if(who.Yvel >= 14 && !_root.loadinglevel)
  1044.             {
  1045.                trace("OUCH FELL TOO FAR! " + who.Yvel);
  1046.                if(!who.dead)
  1047.                {
  1048.                   who.guts.gotoAndStop("rest");
  1049.                   getNormal(who);
  1050.                }
  1051.                who.hp -= 5;
  1052.                if(_root.sel == who)
  1053.                {
  1054.                   _root.retreatcv = _root.maxretreat - 1;
  1055.                   _root.turncv = 1;
  1056.                   _root.getTurn(true);
  1057.                }
  1058.             }
  1059.             who.onground = true;
  1060.             who.virty -= 1;
  1061.             who.Yvel = 1;
  1062.             _loc3_ += 1;
  1063.             if(!Key.isDown(38))
  1064.             {
  1065.                who.jumping = false;
  1066.             }
  1067.             if(_loc3_ > 10 && who.startcv >= 2)
  1068.             {
  1069.                who._x = who.storex;
  1070.                who._y = who.storey - 1;
  1071.                who.virtx = who.storevirtx;
  1072.                who.virty = who.storevirty - 1;
  1073.                who.bounced = true;
  1074.                who.Xvel *= -2;
  1075.             }
  1076.          }
  1077.          while(g.hitTest(who.virtx + who._width / 4,who.virty - 25,true) && !cover.hitTest(who.virtx + who._width / 4,who.virty - 25,true) && who.startcv >= 2)
  1078.          {
  1079.             who._x -= 0.5;
  1080.             who.virtx -= 0.5;
  1081.          }
  1082.          while(g.hitTest(who.virtx - who._width / 4,who.virty - 25,true) && !cover.hitTest(who.virtx - who._width / 4,who.virty - 25,true) && who.startcv >= 2)
  1083.          {
  1084.             who._x += 0.5;
  1085.             who.virtx += 0.5;
  1086.          }
  1087.          if(who.mycurx != who.myprevx || who.mycury != who.myprevy || who.startcv < 2)
  1088.          {
  1089.             who.startcv += 1;
  1090.             getNormal(who);
  1091.          }
  1092.          lookahead2(who);
  1093.          who.myprevx = who.mycurx;
  1094.          who.myprevy = who.mycury;
  1095.          if(who._y > 588 && !_root.loadinglevel)
  1096.          {
  1097.             if(!who.drowned)
  1098.             {
  1099.                splooshsound.start();
  1100.                who.drowned = true;
  1101.             }
  1102.             who.hp -= who.hp;
  1103.             who._visible = false;
  1104.             who.dead = true;
  1105.             if(_root.sel == who)
  1106.             {
  1107.                _root.retreatcv = _root.maxretreat;
  1108.                turncv = 1;
  1109.             }
  1110.             updateHP();
  1111.          }
  1112.          if(who._x > 2900 && !_root.loadinglevel || who._x < 90 && !_root.loadinglevel)
  1113.          {
  1114.             if(!who.drowned)
  1115.             {
  1116.                splooshsound.start();
  1117.                who.drowned = true;
  1118.             }
  1119.             who.hp -= who.hp;
  1120.             who._visible = false;
  1121.             who.dead = true;
  1122.             if(_root.sel == who)
  1123.             {
  1124.                _root.retreatcv = _root.maxretreat;
  1125.                turncv = 1;
  1126.             }
  1127.             updateHP();
  1128.          }
  1129.       }
  1130.    }
  1131. }
  1132. function lookahead2(who)
  1133. {
  1134.    var _loc6_ = who.virtx + who.Xvel;
  1135.    var _loc5_ = who.virty + who.Yvel;
  1136.    if(g.hitTest(_loc6_,_loc5_,true) && !cover.hitTest(_loc6_,_loc5_,true) && !who.onground)
  1137.    {
  1138.       var _loc4_ = Math.atan2(who.Yvel,who.Xvel);
  1139.       var _loc3_ = Math.cos(_loc4_);
  1140.       var _loc2_ = Math.sin(_loc4_);
  1141.       while(!g.hitTest(who.virtx,who.virty,true) || cover.hitTest(who.virtx,who.virty,true))
  1142.       {
  1143.          who._x += _loc3_;
  1144.          who.virtx += _loc3_;
  1145.          who._y += _loc2_;
  1146.          who.virty += _loc2_;
  1147.       }
  1148.    }
  1149.    else
  1150.    {
  1151.       who._y += who.Yvel;
  1152.       var _loc7_ = Math.abs(who.Xvel);
  1153.       if(_loc7_ < 1)
  1154.       {
  1155.          who.Xvel = 0;
  1156.       }
  1157.       who._x += who.Xvel;
  1158.       if(who.onground)
  1159.       {
  1160.          who.Xvel *= 0.3;
  1161.       }
  1162.       else
  1163.       {
  1164.          who.Xvel *= 0.9;
  1165.       }
  1166.    }
  1167. }
  1168. function alignAll()
  1169. {
  1170.    dudes._x = g._x;
  1171.    dudes._y = g._y;
  1172.    pw._x = g._x;
  1173.    pw._y = g._y;
  1174.    cover._x = g._x;
  1175.    cover._y = g._y;
  1176.    backy._x = - g._x;
  1177.    backy._y = - g._y;
  1178.    water._x = 0;
  1179.    water._y = g._y + 560;
  1180. }
  1181. function centerOn(who)
  1182. {
  1183.    var _loc4_ = 350 - who._x;
  1184.    var _loc2_ = _loc4_ - g._x;
  1185.    g._x += _loc2_ / 8;
  1186.    var _loc3_ = 225 - who._y;
  1187.    var _loc5_ = _loc3_ - g._y;
  1188.    g._y += _loc5_ / 8;
  1189.    var _loc6_ = Math.abs(_loc2_);
  1190.    lockedin = false;
  1191.    if(_loc6_ < 1)
  1192.    {
  1193.       g._x = _loc4_;
  1194.       g._y = _loc3_;
  1195.       _root.lockedin = true;
  1196.    }
  1197.    if(_root.g._x >= -120 || _root.g._x <= -2120)
  1198.    {
  1199.       _root.lockedin = true;
  1200.    }
  1201.    alignAll();
  1202. }
  1203. function effectsWaiter()
  1204. {
  1205.    var rdytoroll = true;
  1206.    v = 0;
  1207.    while(v < team0.length)
  1208.    {
  1209.       var chker = eval("dudes.good" + v);
  1210.       var absy = Math.abs(chker.Yvel);
  1211.       var absx = Math.abs(chker.Xvel);
  1212.       if(absy > 1 || !chker.onground || absx > 1)
  1213.       {
  1214.          if(!_root.sel.retreating)
  1215.          {
  1216.             rdytoroll = false;
  1217.          }
  1218.       }
  1219.       v++;
  1220.    }
  1221.    v = 0;
  1222.    while(v < team1.length)
  1223.    {
  1224.       var chker = eval("dudes.bad" + v);
  1225.       var absy = Math.abs(chker.Yvel);
  1226.       var absx = Math.abs(chker.Xvel);
  1227.       if(absy > 1 || !chker.onground || absx > 1)
  1228.       {
  1229.          if(!_root.sel.retreating)
  1230.          {
  1231.             rdytoroll = false;
  1232.          }
  1233.       }
  1234.       v++;
  1235.    }
  1236.    if(rdytoroll)
  1237.    {
  1238.       v = 0;
  1239.       while(v < team0.length)
  1240.       {
  1241.          var thing = eval("dudes.good" + v);
  1242.          while(g.hitTest(thing.virtx,thing.virty,true) && !cover.hitTest(thing.virtx,thing.virty,true))
  1243.          {
  1244.             thing._y -= 0.1;
  1245.             thing.virty -= 0.1;
  1246.          }
  1247.          if(!thing.rec && thing.needtorecover && thing != _root.sel && !thing.dead)
  1248.          {
  1249.             thing.guts.gotoAndStop("recover");
  1250.          }
  1251.          v++;
  1252.       }
  1253.       v = 0;
  1254.       while(v < team1.length)
  1255.       {
  1256.          var thing = eval("dudes.bad" + v);
  1257.          while(g.hitTest(thing.virtx,thing.virty,true) && !cover.hitTest(thing.virtx,thing.virty,true))
  1258.          {
  1259.             thing._y -= 0.1;
  1260.             thing.virty -= 0.1;
  1261.          }
  1262.          if(!thing.rec && thing.needtorecover && thing != _root.sel && !thing.dead)
  1263.          {
  1264.             thing.guts.gotoAndStop("recover");
  1265.          }
  1266.          if(thing == _root.sel && _root.aion && !thing.rec && thing.needtorecover && !thing.dead)
  1267.          {
  1268.             thing.guts.gotoAndStop("recover");
  1269.          }
  1270.          v++;
  1271.       }
  1272.       var retreat = true;
  1273.       _root.waitforretreat = false;
  1274.       _root.sel.aiming = false;
  1275.       _root.sel.retreating = true;
  1276.       _root.waiting = false;
  1277.       _root.physactive = false;
  1278.    }
  1279.    if(retreat)
  1280.    {
  1281.       _root.retreatcv += 1;
  1282.       if(_root.masterturn == "good")
  1283.       {
  1284.          _root.shownum0 = Math.floor(_root.maxretreat - retreatcv);
  1285.       }
  1286.       else
  1287.       {
  1288.          _root.shownum1 = Math.floor(_root.maxretreat - retreatcv);
  1289.          if(aion && !sel.dead)
  1290.          {
  1291.             if(_root.sel._xscale == 100)
  1292.             {
  1293.                if(g.hitTest(_root.sel.virtx + 5,_root.sel.virty + 10,true) && !cover.hitTest(_root.sel.virtx + 5,_root.sel.virty + 10,true))
  1294.                {
  1295.                   _root.sel.needtorecover = false;
  1296.                   _root.sel.guts.gotoAndStop("walk");
  1297.                   _root.sel.gx = _root.sel._x;
  1298.                   if(sel.gx <= sel.px + 3 && sel.px != undefined)
  1299.                   {
  1300.                      _root.sel.Yvel -= _root.sel.jmpht;
  1301.                      _root.sel._y -= _root.sel.jmpht;
  1302.                      _root.sel.virty -= _root.sel.jmpht;
  1303.                      jumpsound.start();
  1304.                   }
  1305.                   _root.sel.Xvel += 6;
  1306.                   if(!sel.jumping)
  1307.                   {
  1308.                      _root.sel.px = _root.sel._x;
  1309.                   }
  1310.                }
  1311.                else
  1312.                {
  1313.                   _root.sel.guts.gotoAndStop("rest");
  1314.                }
  1315.             }
  1316.             if(_root.sel._xscale == -100)
  1317.             {
  1318.                if(g.hitTest(_root.sel.virtx - 5,_root.sel.virty + 10,true) && !cover.hitTest(_root.sel.virtx - 5,_root.sel.virty + 10,true))
  1319.                {
  1320.                   _root.sel.needtorecover = false;
  1321.                   _root.sel.guts.gotoAndStop("walk");
  1322.                   _root.sel.gx = _root.sel._x;
  1323.                   if(sel.gx >= sel.px - 3 && sel.px != undefined)
  1324.                   {
  1325.                      _root.sel.Yvel -= _root.sel.jmpht;
  1326.                      _root.sel._y -= _root.sel.jmpht;
  1327.                      _root.sel.virty -= _root.sel.jmpht;
  1328.                      jumpsound.start();
  1329.                   }
  1330.                   _root.sel.Xvel -= 6;
  1331.                   if(!sel.jumping)
  1332.                   {
  1333.                      _root.sel.px = _root.sel._x;
  1334.                   }
  1335.                }
  1336.                else
  1337.                {
  1338.                   _root.sel.guts.gotoAndStop("rest");
  1339.                }
  1340.             }
  1341.          }
  1342.       }
  1343.    }
  1344.    if(_root.retreatcv >= _root.maxretreat)
  1345.    {
  1346.       v = 0;
  1347.       while(v < team0.length)
  1348.       {
  1349.          var thing = eval("dudes.good" + v);
  1350.          thing.rec = false;
  1351.          thing.needtorecover = false;
  1352.          v++;
  1353.       }
  1354.       v = 0;
  1355.       while(v < team1.length)
  1356.       {
  1357.          var thing = eval("dudes.bad" + v);
  1358.          thing.rec = false;
  1359.          thing.needtorecover = false;
  1360.          v++;
  1361.       }
  1362.       if(!sel.dead)
  1363.       {
  1364.          _root.sel.guts.gotoAndStop("rest");
  1365.       }
  1366.       _root.retreatcv = 0;
  1367.       _root.sel.retreating = false;
  1368.       _root.sel.Yvel = 0;
  1369.       _root.sel.Xvel = 0;
  1370.       getNormal(_root.sel);
  1371.       clearInterval(_root.waitforit);
  1372.       clearInterval(_root.effectsWaiter);
  1373.       while(!g.hitTest(_root.sel.virtx,_root.sel.virty,true) || cover.hitTest(_root.sel.virtx,_root.sel.virty,true))
  1374.       {
  1375.          _root.sel._y += 0.5;
  1376.          _root.sel.virty += 0.5;
  1377.       }
  1378.       while(g.hitTest(_root.sel.virtx,_root.sel.virty,true) && !cover.hitTest(_root.sel.virtx,_root.sel.virty,true))
  1379.       {
  1380.          _root.sel._y -= 0.1;
  1381.          _root.sel.virty -= 0.1;
  1382.       }
  1383.       getTurn(true);
  1384.    }
  1385. }
  1386. function testSplode(circ)
  1387. {
  1388.    var rad = circ._width / 2;
  1389.    var centx = circ._x + g._x;
  1390.    var centy = circ._y + g._y;
  1391.    r = 0;
  1392.    while(r < rad)
  1393.    {
  1394.       p = 1;
  1395.       while(p < 45)
  1396.       {
  1397.          var day = centy + Math.sin(p) * r;
  1398.          var dax = centx + Math.cos(p) * r;
  1399.          b = 0;
  1400.          while(b < team0.length)
  1401.          {
  1402.             var thing = eval("dudes.good" + b);
  1403.             if(thing.hitTest(dax,day,true) && !thing.beenhit)
  1404.             {
  1405.                applySplode(thing,centx,centy,dax,day,circ._width);
  1406.             }
  1407.             b++;
  1408.          }
  1409.          b = 0;
  1410.          while(b < team1.length)
  1411.          {
  1412.             var thing = eval("dudes.bad" + b);
  1413.             if(thing.hitTest(dax,day,true) && !thing.beenhit)
  1414.             {
  1415.                applySplode(thing,centx,centy,dax,day,circ._width);
  1416.             }
  1417.             b++;
  1418.          }
  1419.          p++;
  1420.       }
  1421.       r += 5;
  1422.    }
  1423.    b = 0;
  1424.    while(b < team0.length)
  1425.    {
  1426.       var thing = eval("dudes.good" + b);
  1427.       thing.beenhit = false;
  1428.       b++;
  1429.    }
  1430.    b = 0;
  1431.    while(b < team1.length)
  1432.    {
  1433.       var thing = eval("dudes.bad" + b);
  1434.       thing.beenhit = false;
  1435.       b++;
  1436.    }
  1437. }
  1438. function applySplode(thing, centx, centy, dax, day, powa)
  1439. {
  1440.    thing.beenhit = true;
  1441.    if(!thing.dead && thing.hp > 0)
  1442.    {
  1443.       thing.guts.gotoAndStop("hit");
  1444.       thing.needtorecover = true;
  1445.       thing.onground = false;
  1446.       var _loc7_ = centy - day;
  1447.       var _loc8_ = centx - dax;
  1448.       if(_loc7_ == 0)
  1449.       {
  1450.          _loc7_ = -1;
  1451.       }
  1452.       var _loc14_ = Math.sqrt(_loc7_ * _loc7_ + _loc8_ * _loc8_);
  1453.       var _loc10_ = Math.atan(_loc8_ / _loc7_);
  1454.       var _loc9_ = 100 - _loc14_;
  1455.       var _loc5_ = Math.cos(_loc10_) * _loc9_ / 2.5;
  1456.       var _loc6_ = - Math.abs(Math.sin(_loc10_) * _loc9_ / 10);
  1457.       if(_loc8_ > 0)
  1458.       {
  1459.          if(_loc5_ > 0)
  1460.          {
  1461.             _loc5_ *= -1;
  1462.          }
  1463.       }
  1464.       if(projtype == 3)
  1465.       {
  1466.          _loc6_ *= 4;
  1467.          _loc5_ *= 1.5;
  1468.       }
  1469.       thing.Xvel = _loc5_;
  1470.       thing.Yvel = _loc6_;
  1471.       thing.virtx = dudes._x + thing._x;
  1472.       thing.virty = dudes._y + thing._y;
  1473.       var _loc13_ = thing.virtx + thing.Xvel * 1.5;
  1474.       var _loc12_ = thing.virty + thing.Yvel * 1.5;
  1475.       if(g.hitTest(_loc13_,_loc12_,true) && !cover.hitTest(_loc13_,_loc12_,true))
  1476.       {
  1477.          var _loc11_ = Math.atan2(thing.Yvel,thing.Xvel);
  1478.          var _loc4_ = Math.cos(_loc11_);
  1479.          var _loc3_ = Math.sin(_loc11_);
  1480.          while(!g.hitTest(thing.virtx,thing.virty,true) || cover.hitTest(thing.virtx,thing.virty,true))
  1481.          {
  1482.             thing._x += _loc4_;
  1483.             thing.virtx += _loc4_;
  1484.             thing._y += _loc3_;
  1485.             thing.virty += _loc3_;
  1486.          }
  1487.          getNormal(who);
  1488.       }
  1489.       else
  1490.       {
  1491.          thing._x += thing.Xvel;
  1492.          thing._y += thing.Yvel;
  1493.       }
  1494.       if(!_root.aion || _root.masterturn == "good")
  1495.       {
  1496.          thing.hp -= Math.floor(Math.abs(_loc5_) + Math.abs(_loc6_));
  1497.       }
  1498.       if(_root.aion && masterturn == "bad")
  1499.       {
  1500.          if(thing.typ == "good")
  1501.          {
  1502.             thing.hp -= Math.floor(Math.abs(_loc5_) + Math.abs(_loc6_)) * 2;
  1503.          }
  1504.          else
  1505.          {
  1506.             thing.hp -= Math.floor(Math.abs(_loc5_) + Math.abs(_loc6_));
  1507.          }
  1508.       }
  1509.       if(thing.hp <= 0)
  1510.       {
  1511.          thing.hp = 0;
  1512.          thing.guts.gotoAndStop("dead");
  1513.          thing._xscale = 100;
  1514.          thing.cacheAsBitmap = true;
  1515.          thing.dead = true;
  1516.       }
  1517.       if(thing == _root.sel)
  1518.       {
  1519.          thing.inv = true;
  1520.       }
  1521.       updateHP();
  1522.    }
  1523. }
  1524. function makeDivot(dax, day, size, who)
  1525. {
  1526.    f = pw.attachMovie("circ","circ" + circcount,circcount);
  1527.    sp = _root.dudes.attachMovie("bigsplode","bigsplode",dudes.getNextHighestDepth());
  1528.    sp._x = dax;
  1529.    sp._y = day + size / 2.2;
  1530.    while(sp._width < size / 2)
  1531.    {
  1532.       sp._xscale += 1;
  1533.       sp._yscale = sp._xscale;
  1534.    }
  1535.    f._x = dax;
  1536.    f._y = day;
  1537.    f._width = size;
  1538.    f._height = size;
  1539.    circcount += 1;
  1540.    _root.firing = false;
  1541.    if(!_root.loadinglevel && !_root.beenreset)
  1542.    {
  1543.       var _loc3_ = who;
  1544.       _root.airtotal -= 1;
  1545.       if(!_loc3_.airstrike || _root.airtotal == 0)
  1546.       {
  1547.          _root.physactive = true;
  1548.          _root.waiting = true;
  1549.          _root.effectcv = 0;
  1550.          _root.retreatcv = 0;
  1551.          _root.testingtime = false;
  1552.          _root.waitforit = setInterval(effectsWaiter,100);
  1553.          _root.beenreset = true;
  1554.       }
  1555.       if(size > 0)
  1556.       {
  1557.          testSplode(f);
  1558.          splodesound.start();
  1559.       }
  1560.       _loc3_.unloadMovie();
  1561.       _loc3_.removeMovieClip();
  1562.       _loc3_.stopit = true;
  1563.       _loc3_.exit = true;
  1564.       delete _loc3_.onEnterFrame;
  1565.    }
  1566. }
  1567. function traceX()
  1568. {
  1569.    p = 0;
  1570.    while(p < team0.length)
  1571.    {
  1572.       var thing = eval("dudes.good" + p);
  1573.       p++;
  1574.    }
  1575.    p = 0;
  1576.    while(p < team1.length)
  1577.    {
  1578.       var thing = eval("dudes.bad" + p);
  1579.       p++;
  1580.    }
  1581. }
  1582. function runBounce(who)
  1583. {
  1584.    tinksound.start();
  1585.    var _loc2_ = Math.abs(who.Xvel) + Math.abs(who.Yvel) * 0.2;
  1586.    if(_loc2_ < 0.5)
  1587.    {
  1588.       who.stopit = true;
  1589.    }
  1590.    while(g.hitTest(who.virtx,who.topy,true) && !cover.hitTest(who.virtx,who.topy,true) && who.Yvel < 0)
  1591.    {
  1592.       who._y += 0.5;
  1593.       who.virty += 0.5;
  1594.       who.topy += 0.5;
  1595.    }
  1596.    while(g.hitTest(who.virtx,who.boty,true) && !cover.hitTest(who.virtx,who.boty,true) && who.Yvel > 0)
  1597.    {
  1598.       who._y -= 0.5;
  1599.       who.virty -= 0.5;
  1600.       who.boty -= 0.5;
  1601.    }
  1602.    getNormal(who);
  1603.    who._rotation -= 90;
  1604.    var _loc6_ = who._rotation;
  1605.    var _loc3_ = _loc6_ * 0.017453292519943295;
  1606.    var _loc5_ = who.Xvel * 0.3;
  1607.    var _loc4_ = 0.5;
  1608.    who.Xvel = Math.cos(_loc3_) * _loc2_ + _loc5_;
  1609.    who.Yvel = Math.sin(_loc3_) * (_loc2_ * _loc4_);
  1610.    who._x += Math.cos(_loc3_) * _loc2_ + _loc5_;
  1611.    who._y += Math.sin(_loc3_) * (_loc2_ * _loc4_);
  1612.    who.virtx += Math.cos(_loc3_) * _loc2_ + _loc5_;
  1613.    who.virty += Math.sin(_loc3_) * (_loc2_ * _loc4_);
  1614.    who.rightx += Math.cos(_loc3_) * _loc2_ + _loc5_;
  1615.    who.leftx += Math.cos(_loc3_) * _loc2_ + _loc5_;
  1616.    who.topy += Math.sin(_loc3_) * (_loc2_ * _loc4_);
  1617.    who.boty += Math.sin(_loc3_) * (_loc2_ * _loc4_);
  1618. }
  1619. function lookahead(who, typ, origin)
  1620. {
  1621.    if(typ == 1)
  1622.    {
  1623.       var beensploded = false;
  1624.       var x1 = who.virtx;
  1625.       var x2 = who.virtx + who.Xvel;
  1626.       var y1 = who.virty;
  1627.       var y2 = who.virty + who.Yvel;
  1628.       var distx = x2 - x1;
  1629.       var disty = y2 - y1;
  1630.       var angle = Math.atan2(disty,distx);
  1631.       var gox = Math.cos(angle);
  1632.       var goy = Math.sin(angle);
  1633.       storex = who._x;
  1634.       storey = who._y;
  1635.       if(x1 < x2)
  1636.       {
  1637.          while(x1 < x2)
  1638.          {
  1639.             x1 += gox;
  1640.             y1 += goy;
  1641.             storex += gox;
  1642.             storey += goy;
  1643.             t = 0;
  1644.             while(t < team0.length)
  1645.             {
  1646.                var yib = eval("dudes.good" + t);
  1647.                if(yib.hittable)
  1648.                {
  1649.                   if(origin._xscale == 100 && yib._x > origin._x + 5 || origin._xscale == -100 && yib._x < origin._x - 5 || who.airstrike)
  1650.                   {
  1651.                      if(yib.hitTest(x1,y1,true) && yib != _root.sel && !beensploded && !yib.dead)
  1652.                      {
  1653.                         who._x = yib._x;
  1654.                         who._y = yib._y - yib._height / 2;
  1655.                         who.virtx = yib.virtx;
  1656.                         who.virty = yib.virty - yib._height / 2;
  1657.                         makeDivot(who._x,who._y,who.blastradius,who);
  1658.                         who.airstrike = false;
  1659.                      }
  1660.                   }
  1661.                }
  1662.                t++;
  1663.             }
  1664.             t = 0;
  1665.             while(t < team1.length)
  1666.             {
  1667.                var yib = eval("dudes.bad" + t);
  1668.                if(yib.hittable)
  1669.                {
  1670.                   if(origin._xscale == 100 && yib._x > origin._x + 5 || origin._xscale == -100 && yib._x < origin._x - 5 || who.airstrike)
  1671.                   {
  1672.                      if(yib.hitTest(x1,y1,true) && yib != _root.sel && !beensploded && !yib.dead)
  1673.                      {
  1674.                         who._x = yib._x;
  1675.                         who._y = yib._y - yib._height / 2;
  1676.                         who.virtx = yib.virtx;
  1677.                         who.virty = yib.virty - yib._height / 2;
  1678.                         makeDivot(who._x,who._y,who.blastradius,who);
  1679.                         who.airstrike = false;
  1680.                      }
  1681.                   }
  1682.                }
  1683.                t++;
  1684.             }
  1685.          }
  1686.       }
  1687.       else
  1688.       {
  1689.          while(x1 > x2)
  1690.          {
  1691.             x1 += gox;
  1692.             y1 += goy;
  1693.             storex += gox;
  1694.             storey += goy;
  1695.             t = 0;
  1696.             while(t < team0.length)
  1697.             {
  1698.                var yib = eval("dudes.good" + t);
  1699.                if(yib.hittable)
  1700.                {
  1701.                   if(origin._xscale == 100 && yib._x > origin._x + 5 || origin._xscale == -100 && yib._x < origin._x - 5 || who.airstrike)
  1702.                   {
  1703.                      if(yib.hitTest(x1,y1,true) && yib != _root.sel && !beensploded && !yib.dead)
  1704.                      {
  1705.                         who._x = yib._x;
  1706.                         who._y = yib._y - yib._height / 2;
  1707.                         who.virtx = yib.virtx;
  1708.                         who.virty = yib.virty - yib._height / 2;
  1709.                         makeDivot(who._x,who._y,who.blastradius,who);
  1710.                         who.airstrike = false;
  1711.                         beensploded = true;
  1712.                      }
  1713.                   }
  1714.                }
  1715.                t++;
  1716.             }
  1717.             t = 0;
  1718.             while(t < team1.length)
  1719.             {
  1720.                var yib = eval("dudes.bad" + t);
  1721.                if(yib.hittable)
  1722.                {
  1723.                   if(origin._xscale == 100 && yib._x > origin._x + 5 || origin._xscale == -100 && yib._x < origin._x - 5 || who.airstrike)
  1724.                   {
  1725.                      if(yib.hitTest(x1,y1,true) && yib != _root.sel && !beensploded && !yib.dead)
  1726.                      {
  1727.                         who._x = yib._x;
  1728.                         who._y = yib._y - yib._height / 2;
  1729.                         who.virtx = yib.virtx;
  1730.                         who.virty = yib.virty - yib._height / 2;
  1731.                         makeDivot(who._x,who._y,who.blastradius,who);
  1732.                         who.airstrike = false;
  1733.                         beensploded = true;
  1734.                      }
  1735.                   }
  1736.                }
  1737.                t++;
  1738.             }
  1739.          }
  1740.       }
  1741.    }
  1742.    var nextx = who.virtx + who.Xvel;
  1743.    var nexty = who.virty + who.Yvel;
  1744.    if(g.hitTest(nextx,nexty,true) && !cover.hitTest(nextx,nexty,true))
  1745.    {
  1746.       var rads = who._rotation * 0.017453292519943295;
  1747.       var gox = Math.cos(rads);
  1748.       var goy = Math.sin(rads);
  1749.       var cv = 0;
  1750.       while(!g.hitTest(who.virtx,who.virty,true) && cv < 400 || cover.hitTest(who.virtx,who.virty,true) && cv < 400)
  1751.       {
  1752.          cv++;
  1753.          who._x += gox;
  1754.          who.virtx += gox;
  1755.          who._y += goy;
  1756.          who.virty += goy;
  1757.       }
  1758.       if(typ == 1)
  1759.       {
  1760.          makeDivot(who._x,who._y,who.blastradius,who);
  1761.       }
  1762.    }
  1763.    else
  1764.    {
  1765.       who._x += who.Xvel;
  1766.       who.Xvel *= 0.99;
  1767.       who._y += who.Yvel;
  1768.       who.Yvel += 0.7;
  1769.    }
  1770. }
  1771. function cannonBall(who)
  1772. {
  1773.    who.cv += 1;
  1774.    if(who.virty < 0 && who.virtx > 0 && who.virtx < 700)
  1775.    {
  1776.       off = _root.attachMovie("offscreen","offscreen",105);
  1777.       off._x = who.virtx;
  1778.       off._y = 50;
  1779.       off.pointer._rotation = -90;
  1780.       off.dist = Math.floor(who.virty - 50);
  1781.    }
  1782.    else if(off._x != undefined && who.virtx > 0 && who.virtx < 700)
  1783.    {
  1784.       off._visible = false;
  1785.       off.unloadMovie();
  1786.       off.removeMovieClip();
  1787.    }
  1788.    if(who.virtx < 0 || who.virtx > 700)
  1789.    {
  1790.       off = _root.attachMovie("offscreen","offscreen",105);
  1791.       if(who.virty < 430)
  1792.       {
  1793.          off._y = who.virty;
  1794.       }
  1795.       else
  1796.       {
  1797.          off._y = 430;
  1798.       }
  1799.       if(who.virtx < 0)
  1800.       {
  1801.          off._x = 50;
  1802.          off.pointer._rotation = -180;
  1803.          off.dist = Math.floor(who.virtx);
  1804.       }
  1805.       if(who.virtx > 700)
  1806.       {
  1807.          off._x = 650;
  1808.          off.dist = Math.floor(who.virtx - 700);
  1809.       }
  1810.    }
  1811.    if(who.cv == 60)
  1812.    {
  1813.       who.gotoAndStop("blink");
  1814.    }
  1815.    if(who.cv > 90)
  1816.    {
  1817.       delete who.onEnterFrame;
  1818.       off._visible = false;
  1819.       off.unloadMovie();
  1820.       off.unloadMovieClip();
  1821.       who.stopit = true;
  1822.       who.exit = true;
  1823.       makeDivot(who._x,who._y,who.blastradius,who);
  1824.       _root.physactive = true;
  1825.       _root.waiting = true;
  1826.       _root.firing = false;
  1827.       who.unloadMovie();
  1828.       who.removeMovieClip();
  1829.    }
  1830.    if(!who.stopit)
  1831.    {
  1832.       who.virtx = dudes._x + who._x;
  1833.       who.virty = dudes._y + who._y;
  1834.       who.leftx = dudes._x + who._x - who._width / 3 + who.Xvel / 2;
  1835.       who.rightx = dudes._x + who._x + who._width / 3 + who.Xvel / 2;
  1836.       who.topy = dudes._y + who._y - who._height / 3 + who.Yvel / 2;
  1837.       who.boty = dudes._y + who._y + who._height / 3 + who.Yvel / 2;
  1838.       lookahead(who,0);
  1839.       centerOn(who);
  1840.       who.angle = Math.atan2(who.Yvel,who.Xvel);
  1841.       who.finale = who.angle * 180 / 3.141592653589793;
  1842.       who._rotation = who.finale;
  1843.       if(g.hitTest(who.virtx,who.virty,true) && !cover.hitTest(who.virtx,who.virty,true) || g.hitTest(who.leftx,who.virty,true) && !cover.hitTest(who.leftx,who.virty,true) || g.hitTest(who.rightx,who.virty,true) && !cover.hitTest(who.rightx,who.virty,true) || g.hitTest(who.virtx,who.topy,true) && !cover.hitTest(who.virtx,who.topy,true) || g.hitTest(who.virtx,who.boty,true) && !cover.hitTest(who.virtx,who.boty,true))
  1844.       {
  1845.          getNormal(who);
  1846.          runBounce(who);
  1847.       }
  1848.    }
  1849.    else
  1850.    {
  1851.       who.Xvel = 0;
  1852.       who.Yvel += 0.7;
  1853.       who._y += who.Yvel;
  1854.       who.virty += who.Yvel;
  1855.       while(g.hitTest(who.virtx,who.virty,true) && !cover.hitTest(who.virtx,who.virty,true))
  1856.       {
  1857.          who._y -= 1;
  1858.          who.virty -= 1;
  1859.       }
  1860.       getNormal(who);
  1861.    }
  1862.    if(who._y > 588)
  1863.    {
  1864.       who.stopit = true;
  1865.       who.exit = true;
  1866.       _root.physactive = true;
  1867.       _root.waiting = true;
  1868.       _root.firing = false;
  1869.       makeDivot(who._x,who._y,0,who);
  1870.       off._visible = false;
  1871.       off.unloadMovie();
  1872.       off.unloadMovieClip();
  1873.       splooshsound.start();
  1874.       delete who.onEnterFrame;
  1875.       who.unloadMovie();
  1876.       who.removeMovieClip();
  1877.    }
  1878. }
  1879. function powerBall(who, origin)
  1880. {
  1881.    who.cv += 1;
  1882.    if(!origin.hittable)
  1883.    {
  1884.       var _loc5_ = who._x - origin._x;
  1885.       var _loc4_ = who._y - origin._y;
  1886.       if(_loc5_ != 0 && _loc4_ != 0)
  1887.       {
  1888.          who.closeness = Math.sqrt(_loc5_ * _loc5_ + _loc4_ * _loc4_);
  1889.       }
  1890.       if(who.closeness > 75)
  1891.       {
  1892.          origin.hittable = true;
  1893.       }
  1894.    }
  1895.    if(who.virty < 0 && who.virtx > 0 && who.virtx < 700)
  1896.    {
  1897.       off = _root.attachMovie("offscreen","offscreen",105);
  1898.       off._x = who.virtx;
  1899.       off._y = 50;
  1900.       off.pointer._rotation = -90;
  1901.       off.dist = Math.floor(who.virty - 50);
  1902.    }
  1903.    else if(off._x != undefined && who.virtx > 0 && who.virtx < 700)
  1904.    {
  1905.       off._visible = false;
  1906.       off.unloadMovie();
  1907.       off.unloadMovieClip();
  1908.    }
  1909.    if(who.virtx < 0 || who.virtx > 700)
  1910.    {
  1911.       off = _root.attachMovie("offscreen","offscreen",105);
  1912.       if(who.virty < 430)
  1913.       {
  1914.          off._y = who.virty;
  1915.       }
  1916.       else
  1917.       {
  1918.          off._y = 430;
  1919.       }
  1920.       if(who.virtx < 0)
  1921.       {
  1922.          off._x = 50;
  1923.          off.pointer._rotation = -180;
  1924.          off.dist = Math.floor(who.virtx);
  1925.       }
  1926.       if(who.virtx > 700)
  1927.       {
  1928.          off._x = 650;
  1929.          off.dist = Math.floor(who.virtx - 700);
  1930.       }
  1931.    }
  1932.    if(who._y > 588)
  1933.    {
  1934.       who.stopit = true;
  1935.       who.exit = true;
  1936.       _root.physactive = true;
  1937.       _root.waiting = true;
  1938.       _root.firing = false;
  1939.       makeDivot(who._x,who._y,0,who);
  1940.       off._visible = false;
  1941.       off.unloadMovie();
  1942.       off.removeMovieClip();
  1943.       splooshsound.start();
  1944.       delete who.onEnterFrame;
  1945.       who.unloadMovie();
  1946.       who.removeMovieClip();
  1947.    }
  1948.    if(!who.stopit)
  1949.    {
  1950.       who.virtx = dudes._x + who._x;
  1951.       who.virty = dudes._y + who._y;
  1952.       who.leftx = dudes._x + who._x - who._width / 3 + who.Xvel / 2;
  1953.       who.rightx = dudes._x + who._x + who._width / 3 + who.Xvel / 2;
  1954.       who.topy = dudes._y + who._y - who._height / 3 + who.Yvel / 2;
  1955.       who.boty = dudes._y + who._y + who._height / 3 + who.Yvel / 2;
  1956.       lookahead(who,1,origin);
  1957.       centerOn(who);
  1958.       who.angle = Math.atan2(who.Yvel,who.Xvel);
  1959.       who.finale = who.angle * 180 / 3.141592653589793;
  1960.       who._rotation = who.finale;
  1961.       if(g.hitTest(who.virtx,who.virty,true) && !cover.hitTest(who.virtx,who.virty,true) || g.hitTest(who.leftx,who.virty,true) && !cover.hitTest(who.leftx,who.virty,true) || g.hitTest(who.rightx,who.virty,true) && !cover.hitTest(who.rightx,who.virty,true) || g.hitTest(who.virtx,who.topy,true) && !cover.hitTest(who.virtx,who.topy,true) || g.hitTest(who.virtx,who.boty,true) && !cover.hitTest(who.virtx,who.boty,true))
  1962.       {
  1963.          getNormal(who);
  1964.          makeDivot(who._x,who._y,who.blastradius,who);
  1965.       }
  1966.    }
  1967. }
  1968. function makeProjectile(who, typ)
  1969. {
  1970.    if(typ == 0)
  1971.    {
  1972.       p = _root.dudes.attachMovie("cannonball","proj",99);
  1973.       p.bouncefactor = 3;
  1974.       p.ybounce = 0.9;
  1975.       p.cv = 0;
  1976.       p.ject = true;
  1977.       p.onEnterFrame = function()
  1978.       {
  1979.          cannonBall(this);
  1980.       };
  1981.    }
  1982.    if(typ == 3)
  1983.    {
  1984.       p = _root.dudes.attachMovie("nuke","proj",99);
  1985.       p.bouncefactor = 3;
  1986.       p.ybounce = 0.9;
  1987.       p.cv = 0;
  1988.       p.ject = true;
  1989.       p.onEnterFrame = function()
  1990.       {
  1991.          cannonBall(this);
  1992.       };
  1993.    }
  1994.    if(typ == 1)
  1995.    {
  1996.       p = _root.dudes.attachMovie("powerball","proj",99);
  1997.       p.cv = 0;
  1998.       p.ject = true;
  1999.       who.hittable = false;
  2000.       p.airstrike = false;
  2001.       _root.airstrike = false;
  2002.       p.onEnterFrame = function()
  2003.       {
  2004.          powerBall(this,who);
  2005.       };
  2006.    }
  2007.    p._x = who._x + who.aimer._x;
  2008.    p._y = who._y + who.aimer._y;
  2009.    if(who._xscale == 100)
  2010.    {
  2011.       var _loc5_ = who._rotation + who.aimer._rotation;
  2012.    }
  2013.    else
  2014.    {
  2015.       _loc5_ = who._rotation + who.aimer._rotation * -1 - 180;
  2016.    }
  2017.    var _loc4_ = _loc5_ * 0.017453292519943295;
  2018.    p.gox = Math.cos(_loc4_);
  2019.    p.goy = Math.sin(_loc4_);
  2020.    p.Xvel = p.gox * who.powa;
  2021.    p.Yvel = p.goy * who.powa;
  2022.    checkRicochet(p,true,typ,who);
  2023. }
  2024. function checkRicochet(who, clearem, typ, origin)
  2025. {
  2026.    who.virtx = dudes._x + who._x;
  2027.    who.virty = dudes._y + who._y;
  2028.    var xgoal = who.virtx + who.Xvel;
  2029.    var ygoal = who.virty + who.Yvel;
  2030.    if(typ == 1)
  2031.    {
  2032.       var beensploded = false;
  2033.       var x1 = who.virtx;
  2034.       var x2 = who.virtx + who.Xvel;
  2035.       var y1 = who.virty;
  2036.       var y2 = who.virty + who.Yvel;
  2037.       var distx = x2 - x1;
  2038.       var disty = y2 - y1;
  2039.       var angle = Math.atan2(disty,distx);
  2040.       var gox = Math.cos(angle);
  2041.       var goy = Math.sin(angle);
  2042.       if(x1 < x2)
  2043.       {
  2044.          while(x1 < x2)
  2045.          {
  2046.             x1 += gox;
  2047.             y1 += goy;
  2048.             who._x += gox;
  2049.             who._y += goy;
  2050.             who.virtx += gox;
  2051.             who.virty += goy;
  2052.             t = 0;
  2053.             while(t < team0.length)
  2054.             {
  2055.                var yib = eval("dudes.good" + t);
  2056.                if(yib.hittable)
  2057.                {
  2058.                   if(origin._xscale == 100 && yib._x > origin._x + 5 || origin._xscale == -100 && yib._x < origin._x - 5)
  2059.                   {
  2060.                      if(yib.hitTest(x1,y1,true) && yib != _root.sel && !beensploded && !yib.dead)
  2061.                      {
  2062.                         who._x = yib._x;
  2063.                         who._y = yib._y - yib._height / 2;
  2064.                         who.virtx = yib.virtx;
  2065.                         who.virty = yib.virty - yib._height / 2;
  2066.                         makeDivot(yib._x,yib._y - yib._height / 2,200,who);
  2067.                         beensploded = true;
  2068.                      }
  2069.                   }
  2070.                }
  2071.                t++;
  2072.             }
  2073.             t = 0;
  2074.             while(t < team1.length)
  2075.             {
  2076.                var yib = eval("dudes.bad" + t);
  2077.                if(yib.hittable)
  2078.                {
  2079.                   if(origin._xscale == 100 && yib._x > origin._x + 5 || origin._xscale == -100 && yib._x < origin._x - 5)
  2080.                   {
  2081.                      if(yib.hitTest(x1,y1,true) && yib != _root.sel && !beensploded && !yib.dead)
  2082.                      {
  2083.                         who._x = yib._x;
  2084.                         who._y = yib._y - yib._height / 2;
  2085.                         who.virtx = yib.virtx;
  2086.                         who.virty = yib.virty - yib._height / 2;
  2087.                         makeDivot(yib._x,yib._y - yib._height / 2,200,who);
  2088.                         beensploded = true;
  2089.                      }
  2090.                   }
  2091.                }
  2092.                t++;
  2093.             }
  2094.          }
  2095.       }
  2096.       else
  2097.       {
  2098.          while(x1 > x2)
  2099.          {
  2100.             x1 += gox;
  2101.             y1 += goy;
  2102.             who._x += gox;
  2103.             who._y += goy;
  2104.             who.virtx += gox;
  2105.             who.virty += goy;
  2106.             t = 0;
  2107.             while(t < team0.length)
  2108.             {
  2109.                var yib = eval("dudes.good" + t);
  2110.                if(yib.hittable)
  2111.                {
  2112.                   if(origin._xscale == 100 && yib._x > origin._x + 5 || origin._xscale == -100 && yib._x < origin._x - 5)
  2113.                   {
  2114.                      if(yib.hitTest(x1,y1,true) && yib != _root.sel && !beensploded && !yib.dead)
  2115.                      {
  2116.                         who._x = yib._x;
  2117.                         who._y = yib._y - yib._height / 2;
  2118.                         who.virtx = yib.virtx;
  2119.                         who.virty = yib.virty - yib._height / 2;
  2120.                         makeDivot(yib._x,yib._y - yib._height / 2,200,who);
  2121.                         beensploded = true;
  2122.                      }
  2123.                   }
  2124.                }
  2125.                t++;
  2126.             }
  2127.             t = 0;
  2128.             while(t < team1.length)
  2129.             {
  2130.                var yib = eval("dudes.bad" + t);
  2131.                if(yib.hittable)
  2132.                {
  2133.                   if(origin._xscale == 100 && yib._x > origin._x + 5 || origin._xscale == -100 && yib._x < origin._x - 5)
  2134.                   {
  2135.                      if(yib.hitTest(x1,y1,true) && yib != _root.sel && !beensploded && !yib.dead)
  2136.                      {
  2137.                         who._x = yib._x;
  2138.                         who._y = yib._y - yib._height / 2;
  2139.                         who.virtx = yib.virtx;
  2140.                         who.virty = yib.virty - yib._height / 2;
  2141.                         makeDivot(yib._x,yib._y - yib._height / 2,200,who);
  2142.                         beensploded = true;
  2143.                      }
  2144.                   }
  2145.                }
  2146.                t++;
  2147.             }
  2148.          }
  2149.       }
  2150.    }
  2151.    if(g.hitTest(xgoal,ygoal,true) && !cover.hitTest(xgoal,ygoal,true) && !beensploded)
  2152.    {
  2153.       var cv = 0;
  2154.       while(!g.hitTest(who.virtx,who.virty,true) && cv < 350 || cover.hitTest(who.virtx,who.virty,true) && cv < 350)
  2155.       {
  2156.          cv++;
  2157.          who._x += who.gox;
  2158.          who.virtx += who.gox;
  2159.          who._y += who.goy;
  2160.          who.virty += who.goy;
  2161.       }
  2162.       getNormal(who);
  2163.       if(typ == 0)
  2164.       {
  2165.          runBounce(who);
  2166.       }
  2167.       if(typ == 1)
  2168.       {
  2169.          makeDivot(who._x,who._y,200,who);
  2170.       }
  2171.    }
  2172.    else
  2173.    {
  2174.       who._x += who.Xvel;
  2175.       who._y += who.Yvel;
  2176.    }
  2177.    if(clearem)
  2178.    {
  2179.       clearPointers();
  2180.    }
  2181. }
  2182. function controls()
  2183. {
  2184.    if(!aion || masterturn == "good")
  2185.    {
  2186.       if(Key.isDown(27))
  2187.       {
  2188.          if(_root.sel.aiming)
  2189.          {
  2190.             _root.sel.aiming = false;
  2191.             _root.sel.aimer._visible = false;
  2192.             _root.readytoswitchweapons = false;
  2193.             _root.sel.rdy = false;
  2194.             rdytocharge = false;
  2195.             freshInst(1,sel);
  2196.          }
  2197.       }
  2198.       if(!_root.loadinglevel)
  2199.       {
  2200.          if(_root.selecting)
  2201.          {
  2202.             if(!Key.isDown(83))
  2203.             {
  2204.                sup = true;
  2205.             }
  2206.             else if(sup)
  2207.             {
  2208.                if(_root.abletoswitch)
  2209.                {
  2210.                   getTurn();
  2211.                   switchsound.start();
  2212.                   _root.sel.guts.gotoAndStop("rest");
  2213.                }
  2214.                sup = false;
  2215.             }
  2216.          }
  2217.          if(!Key.isDown(32) && !_root.sel.retreating)
  2218.          {
  2219.             spaceup = true;
  2220.          }
  2221.          else if(spaceup)
  2222.          {
  2223.             if(!_root.sel.retreating)
  2224.             {
  2225.                if(!_root.sel.aiming && !_root.selecting)
  2226.                {
  2227.                   freshInst(2,sel);
  2228.                   powersound.start();
  2229.                   _root.sel.aiming = true;
  2230.                   if(sel.myweaps[0] == 0)
  2231.                   {
  2232.                      _root.projtype = 0;
  2233.                   }
  2234.                   _root.sel.guts.gotoAndStop("aiming");
  2235.                   _root.sel.aimer._visible = true;
  2236.                   _root.sel.aimer.gotoAndPlay(1);
  2237.                   _root.readytoswitchweapons = true;
  2238.                   _root.sel.powa = 0;
  2239.                }
  2240.                if(_root.selecting)
  2241.                {
  2242.                   selsound.start();
  2243.                   selsound.setVolume(30);
  2244.                   freshInst(1);
  2245.                   _root.selecting = false;
  2246.                   _root.turncv = _root.maxturn;
  2247.                   _root.testingtime = true;
  2248.                }
  2249.             }
  2250.             spaceup = false;
  2251.          }
  2252.          if(_root.sel.aiming)
  2253.          {
  2254.             if(!Key.isDown(32))
  2255.             {
  2256.                _root.sel.rdy = true;
  2257.                rdytocharge = true;
  2258.                loopedy = false;
  2259.             }
  2260.             if(Key.isDown(32) && _root.sel.rdy && !_root.teleportation && !_root.airstrike && _root.projtype != 4)
  2261.             {
  2262.                if(rdytocharge)
  2263.                {
  2264.                   clearInst();
  2265.                   chargesound.start();
  2266.                   rdytocharge = false;
  2267.                }
  2268.                _root.readytoswitchweapons = false;
  2269.                var max = 40;
  2270.                var inc = max / 5;
  2271.                if(_root.sel.powa < max)
  2272.                {
  2273.                   _root.sel.powa += 1;
  2274.                }
  2275.                if(sel.powa >= max)
  2276.                {
  2277.                   if(!loopedy)
  2278.                   {
  2279.                      chargesound.stop();
  2280.                      chargeloop.start();
  2281.                      chargeloop.onSoundComplete = function()
  2282.                      {
  2283.                         this.start();
  2284.                      };
  2285.                      loopedy = true;
  2286.                   }
  2287.                }
  2288.                i = 0;
  2289.                while(i < 5)
  2290.                {
  2291.                   var thing = eval("_root.sel.guts.aimclip.arm1.powerthing.pow" + i);
  2292.                   if(_root.sel.powa >= inc * i)
  2293.                   {
  2294.                      thing._visible = true;
  2295.                   }
  2296.                   else
  2297.                   {
  2298.                      thing._visible = false;
  2299.                   }
  2300.                   i++;
  2301.                }
  2302.                _root.sel.buildingup = true;
  2303.             }
  2304.             else if(Key.isDown(32) && !_root.sel.punching)
  2305.             {
  2306.                if(projtype == 4 && !teleportation && !airstrike)
  2307.                {
  2308.                   if(sel.myweaps[3] > 0)
  2309.                   {
  2310.                      sel.myweaps[3] -= 1;
  2311.                   }
  2312.                   clearInst();
  2313.                   _root.sel.punching = true;
  2314.                   _root.sel.guts.gotoAndStop("punch");
  2315.                   d = 0;
  2316.                   while(d < team0.length)
  2317.                   {
  2318.                      var w = eval("_root.dudes.good" + d);
  2319.                      w.bar._visible = false;
  2320.                      w.pointer._visible = false;
  2321.                      d++;
  2322.                   }
  2323.                   d = 0;
  2324.                   while(d < team1.length)
  2325.                   {
  2326.                      var w = eval("_root.dudes.bad" + d);
  2327.                      w.bar._visible = false;
  2328.                      w.pointer._visible = false;
  2329.                      d++;
  2330.                   }
  2331.                   _root.sel.aimer._visible = false;
  2332.                   _root.readytoswitchweapons = false;
  2333.                   _root.sel.buildingup = false;
  2334.                   _root.sel.rdy = false;
  2335.                   _root.waitforretreat = true;
  2336.                   _root.testingtime = false;
  2337.                }
  2338.             }
  2339.          }
  2340.          if(!Key.isDown(32) && _root.sel.buildingup)
  2341.          {
  2342.             _root.readytoswitchweapons = false;
  2343.             chargesound.stop();
  2344.             chargeloop.stop();
  2345.             throwsound.start();
  2346.             if(sel.myweaps[5] > 0 && projtype == 3)
  2347.             {
  2348.                sel.myweaps[5] -= 1;
  2349.             }
  2350.             if(sel.myweaps[0] > 0 && projtype == 0)
  2351.             {
  2352.                sel.myweaps[0] -= 1;
  2353.             }
  2354.             if(sel.myweaps[1] > 0 && projtype == 1)
  2355.             {
  2356.                sel.myweaps[1] -= 1;
  2357.             }
  2358.             d = 0;
  2359.             while(d < team0.length)
  2360.             {
  2361.                var w = eval("_root.dudes.good" + d);
  2362.                w.bar._visible = false;
  2363.                d++;
  2364.             }
  2365.             d = 0;
  2366.             while(d < team1.length)
  2367.             {
  2368.                var w = eval("_root.dudes.bad" + d);
  2369.                w.bar._visible = false;
  2370.                d++;
  2371.             }
  2372.             _root.sel.buildingup = false;
  2373.             _root.sel.rdy = false;
  2374.             _root.sel.aiming = false;
  2375.             _root.waitforretreat = true;
  2376.             makeProjectile(_root.sel,_root.projtype);
  2377.             _root.sel.guts.gotoAndStop("rest");
  2378.             _root.testingtime = false;
  2379.          }
  2380.          if(!Key.isDown(80))
  2381.          {
  2382.             pup = true;
  2383.          }
  2384.          else if(pup && !_root.teleportation && !_root.airstrike)
  2385.          {
  2386.             if(!panon)
  2387.             {
  2388.                panon = true;
  2389.                _root.attachMovie("pansign","pansign",999);
  2390.             }
  2391.             else
  2392.             {
  2393.                panon = false;
  2394.                pansign.unloadMovie();
  2395.                pansign.removeMovieClip();
  2396.             }
  2397.             pup = false;
  2398.          }
  2399.          if(panon)
  2400.          {
  2401.             if(!_root.teleportation && !_root.airstrike)
  2402.             {
  2403.                if(Key.isDown(39))
  2404.                {
  2405.                   g._x -= panspeed;
  2406.                }
  2407.                if(Key.isDown(37))
  2408.                {
  2409.                   g._x += panspeed;
  2410.                }
  2411.                if(Key.isDown(40))
  2412.                {
  2413.                   g._y -= panspeed;
  2414.                }
  2415.                if(Key.isDown(38))
  2416.                {
  2417.                   g._y += panspeed;
  2418.                }
  2419.             }
  2420.             else
  2421.             {
  2422.                if(Key.isDown(39))
  2423.                {
  2424.                   if(g._x > -2120 && _root.teletubby._x >= 350)
  2425.                   {
  2426.                      g._x -= panspeed;
  2427.                   }
  2428.                   else if(_root.teletubby._x < 700)
  2429.                   {
  2430.                      _root.teletubby._x += panspeed;
  2431.                   }
  2432.                   else
  2433.                   {
  2434.                      _root.teletubby._x = 700;
  2435.                   }
  2436.                }
  2437.                if(Key.isDown(37))
  2438.                {
  2439.                   if(g._x < -120 && _root.teletubby._x < 350)
  2440.                   {
  2441.                      g._x += panspeed;
  2442.                   }
  2443.                   else if(_root.teletubby._x > 0)
  2444.                   {
  2445.                      _root.teletubby._x -= panspeed;
  2446.                   }
  2447.                   else
  2448.                   {
  2449.                      _root.teletubby._x = 0;
  2450.                   }
  2451.                }
  2452.                if(Key.isDown(40))
  2453.                {
  2454.                   if(g._y > -120 && _root.teletubby._y >= 225)
  2455.                   {
  2456.                      g._y -= panspeed;
  2457.                   }
  2458.                   else if(_root.teletubby._y < 450)
  2459.                   {
  2460.                      _root.teletubby._y += panspeed;
  2461.                   }
  2462.                   else
  2463.                   {
  2464.                      _root.teletubby._y = 450;
  2465.                   }
  2466.                }
  2467.                if(Key.isDown(38))
  2468.                {
  2469.                   if(g._y < 500 && _root.teletubby._y < 225)
  2470.                   {
  2471.                      g._y += panspeed;
  2472.                   }
  2473.                   else if(_root.teletubby._y > 0)
  2474.                   {
  2475.                      _root.teletubby._y -= panspeed;
  2476.                   }
  2477.                   else
  2478.                   {
  2479.                      _root.teletubby._y = 0;
  2480.                   }
  2481.                }
  2482.             }
  2483.          }
  2484.          else
  2485.          {
  2486.             if(!_root.selecting && !who.retreating)
  2487.             {
  2488.                if(!_root.sel.aiming)
  2489.                {
  2490.                   if(_root.abletomove)
  2491.                   {
  2492.                      if(Key.isDown(39) && !Key.isDown(37))
  2493.                      {
  2494.                         _root.sel.Xvel += _root.sel.speed;
  2495.                         _root.sel._xscale = 100;
  2496.                         _root.sel.guts.gotoAndStop("walk");
  2497.                         _root.sel.bar._xscale = _root.sel._xscale;
  2498.                      }
  2499.                      if(Key.isDown(37) && !Key.isDown(39))
  2500.                      {
  2501.                         _root.sel.Xvel -= _root.sel.speed;
  2502.                         _root.sel._xscale = -100;
  2503.                         _root.sel.bar._xscale = _root.sel._xscale;
  2504.                         _root.sel.guts.gotoAndStop("walk");
  2505.                      }
  2506.                      if(!Key.isDown(37) && !Key.isDown(39))
  2507.                      {
  2508.                         _root.sel.guts.gotoAndStop("rest");
  2509.                      }
  2510.                      if(Key.isDown(38) && !_root.sel.jumping)
  2511.                      {
  2512.                         _root.sel.Yvel -= _root.sel.jmpht;
  2513.                         _root.sel._y -= _root.sel.jmpht;
  2514.                         _root.sel.virty -= _root.sel.jmpht;
  2515.                         _root.sel.jumping = true;
  2516.                         jumpsound.start();
  2517.                      }
  2518.                   }
  2519.                }
  2520.                if(_root.sel.aiming)
  2521.                {
  2522.                   if(Key.isDown(39) && !Key.isDown(37))
  2523.                   {
  2524.                      _root.sel._xscale = 100;
  2525.                   }
  2526.                   if(Key.isDown(37) && !Key.isDown(39))
  2527.                   {
  2528.                      _root.sel._xscale = -100;
  2529.                   }
  2530.                   if(Key.isDown(38))
  2531.                   {
  2532.                      if(_root.sel.aimer._rotation > -86)
  2533.                      {
  2534.                         _root.sel.aimer._rotation -= 3;
  2535.                      }
  2536.                   }
  2537.                   if(Key.isDown(40))
  2538.                   {
  2539.                      if(_root.sel.aimer._rotation < 86)
  2540.                      {
  2541.                         _root.sel.aimer._rotation += 3;
  2542.                      }
  2543.                   }
  2544.                }
  2545.             }
  2546.             if(!_root.firing && !_root.waiting && !_root.loadinglevel)
  2547.             {
  2548.                centerOn(_root.sel);
  2549.             }
  2550.          }
  2551.       }
  2552.    }
  2553.    else if(!_root.loadinglevel)
  2554.    {
  2555.       if(aion && !_root.gamesup)
  2556.       {
  2557.          centerOn(_root.sel);
  2558.          if(!_root.iknowit)
  2559.          {
  2560.             var maxbing = 9999999;
  2561.             i = 0;
  2562.             while(i < team1.length)
  2563.             {
  2564.                var ub = eval("dudes.bad" + i);
  2565.                if(!ub.dead)
  2566.                {
  2567.                   n = 0;
  2568.                   while(n < team0.length)
  2569.                   {
  2570.                      var tex = eval("dudes.good" + n);
  2571.                      if(!tex.dead)
  2572.                      {
  2573.                         var clobx = ub._x - tex._x;
  2574.                         var cloby = ub._y - tex._y;
  2575.                         var clob = Math.abs(clobx * clobx + cloby * cloby);
  2576.                         if(clob < maxbing)
  2577.                         {
  2578.                            maxbing = clob;
  2579.                            _root.myclosedude = ub;
  2580.                         }
  2581.                      }
  2582.                      n++;
  2583.                   }
  2584.                }
  2585.                i++;
  2586.             }
  2587.             _root.iknowit = true;
  2588.          }
  2589.          if(_root.iknowit && !_root.aiclose)
  2590.          {
  2591.             if(_root.sel != _root.myclosedude)
  2592.             {
  2593.                getTurn();
  2594.             }
  2595.             else
  2596.             {
  2597.                _root.aiclose = true;
  2598.             }
  2599.          }
  2600.          if(_root.aiclose)
  2601.          {
  2602.             if(!_root.aiknown)
  2603.             {
  2604.                _root.sel.guts.gotoAndStop("rest");
  2605.                _root.sel.thinking._visible = true;
  2606.                _root.sel.pointer._visible = false;
  2607.                _root.sel._xscale = 100;
  2608.             }
  2609.             if(_root.lockedin)
  2610.             {
  2611.                if(!_root.aiknown)
  2612.                {
  2613.                   var daindex = chkAIShot();
  2614.                   if(daindex == undefined)
  2615.                   {
  2616.                      trace("I don\'t know what to do!");
  2617.                      _root.getTurn(true);
  2618.                   }
  2619.                   else
  2620.                   {
  2621.                      _root.aiknown = true;
  2622.                      _root.aicv = 0;
  2623.                      _root.sel.thinking._visible = false;
  2624.                      var startrot = -5 - _root.sel._rotation;
  2625.                      _root.sel.aimer._visible = true;
  2626.                      _root.sel.aimer.gotoAndPlay(1);
  2627.                      _root.sel.aimer._rotation = startrot - 3 * daindex;
  2628.                      if(sel.aimer._rotation < -90)
  2629.                      {
  2630.                         _root.sel._xscale = -100;
  2631.                         sel.aimer._rotation = sel._rotation + sel.aimer._rotation * -1 - 180;
  2632.                      }
  2633.                      else
  2634.                      {
  2635.                         _root.sel._xscale = 100;
  2636.                      }
  2637.                      i = 0;
  2638.                      while(i < team0.length)
  2639.                      {
  2640.                         var thing = eval("dudes.good" + i);
  2641.                         thing.bar._visible = false;
  2642.                         i++;
  2643.                      }
  2644.                      i = 0;
  2645.                      while(i < team1.length)
  2646.                      {
  2647.                         var thing = eval("dudes.bad" + i);
  2648.                         thing.bar._visible = false;
  2649.                         i++;
  2650.                      }
  2651.                      _root.projtype = 1;
  2652.                   }
  2653.                }
  2654.             }
  2655.          }
  2656.          if(aiknown)
  2657.          {
  2658.             _root.aicv += 1;
  2659.             if(_root.aicv == 30)
  2660.             {
  2661.                _root.dudes.raytrace.unloadMovie();
  2662.                _root.dudes.raytrace.removeMovieClip();
  2663.                _root.readytoswitchweapons = false;
  2664.                _root.sel.buildingup = false;
  2665.                _root.sel.rdy = false;
  2666.                _root.sel.aiming = false;
  2667.                _root.sel.powa = 34.5;
  2668.                _root.waitforretreat = true;
  2669.                makeProjectile(_root.sel,_root.projtype);
  2670.                _root.sel.guts.gotoAndStop("rest");
  2671.                _root.testingtime = false;
  2672.             }
  2673.          }
  2674.       }
  2675.    }
  2676. }
  2677. function testPunch(who, block)
  2678. {
  2679.    _root.physactive = true;
  2680.    _root.waiting = true;
  2681.    _root.effectcv = 0;
  2682.    _root.retreatcv = 0;
  2683.    _root.testingtime = false;
  2684.    _root.waitforit = setInterval(effectsWaiter,100);
  2685.    _root.beenreset = true;
  2686.    i = 0;
  2687.    while(i < team0.length)
  2688.    {
  2689.       var dude = eval("dudes.good" + i);
  2690.       if(block.hitTest(dude) && dude != who)
  2691.       {
  2692.          if(dude._x < who._x)
  2693.          {
  2694.             var offset = -5;
  2695.          }
  2696.          else
  2697.          {
  2698.             var offset = 5;
  2699.          }
  2700.          applySplode(dude,who.virtx,who.virty,who.virtx + offset,who.virty + offset,150);
  2701.          pp = _root.dudes.attachMovie("punchpoof","poof",989);
  2702.          pp._x = dude._x;
  2703.          pp._y = dude._y - 45;
  2704.          pp._xscale = 105;
  2705.          pp._yscale = pp._xscale;
  2706.       }
  2707.       i++;
  2708.    }
  2709.    i = 0;
  2710.    while(i < team1.length)
  2711.    {
  2712.       var dude = eval("dudes.bad" + i);
  2713.       if(block.hitTest(dude) && dude != who)
  2714.       {
  2715.          if(dude._x < who._x)
  2716.          {
  2717.             var offset = -5;
  2718.          }
  2719.          else
  2720.          {
  2721.             var offset = 5;
  2722.          }
  2723.          applySplode(dude,who.virtx,who.virty,who.virtx + offset,who.virty,150);
  2724.          pp = _root.dudes.attachMovie("punchpoof","poof",989);
  2725.          pp._x = dude._x;
  2726.          pp._y = dude._y - 45;
  2727.          pp._xscale = 105;
  2728.          pp._yscale = pp._xscale;
  2729.       }
  2730.       i++;
  2731.    }
  2732. }
  2733. function chkAIShot()
  2734. {
  2735.    _root.airstrike = false;
  2736.    var who = _root.sel;
  2737.    var rot = -5 - who._rotation;
  2738.    var cv = 0;
  2739.    r = _root.dudes.createEmptyMovieClip("raytrace",989999);
  2740.    var res = new Array();
  2741.    var rescv = 0;
  2742.    while(rot > -175 - who._rotation)
  2743.    {
  2744.       res[rescv] = new Array();
  2745.       res[rescv][0] = 0;
  2746.       res[rescv][1] = 0;
  2747.       var pow = 35;
  2748.       var curx = who._x;
  2749.       var cury = who._y - 30;
  2750.       var dangle = who._rotation + rot;
  2751.       var rads = dangle * 0.017453292519943295;
  2752.       var gox = Math.cos(rads);
  2753.       var goy = Math.sin(rads);
  2754.       var Xvel = gox * pow;
  2755.       var Yvel = goy * pow;
  2756.       _root.starconnect = false;
  2757.       f = 0;
  2758.       while(f < 115)
  2759.       {
  2760.          i = 0;
  2761.          while(i < team0.length)
  2762.          {
  2763.             var dud = eval("dudes.good" + i);
  2764.             var mydx = who._x - dud._x;
  2765.             var mydy = who._y - dud._y;
  2766.             var mydist = Math.sqrt(mydx * mydx + mydy * mydy);
  2767.             if(mydist > 100)
  2768.             {
  2769.                if(!dud.dead)
  2770.                {
  2771.                   var dadistx = curx - dud._x;
  2772.                   var dadisty = cury - dud._y;
  2773.                   var hyp = Math.sqrt(dadistx * dadistx + dadisty * dadisty);
  2774.                   if(hyp < 75)
  2775.                   {
  2776.                      if(_root.debug)
  2777.                      {
  2778.                         t = r.attachMovie("star","test",cv);
  2779.                         t._x = curx;
  2780.                         t._y = cury;
  2781.                      }
  2782.                      curx += Xvel;
  2783.                      cury += Yvel;
  2784.                      cv++;
  2785.                      Xvel *= 0.99;
  2786.                      Yvel += 0.7;
  2787.                      res[rescv][1] += 1;
  2788.                      _root.starconnect = true;
  2789.                      var hitdude = true;
  2790.                   }
  2791.                   else
  2792.                   {
  2793.                      var hitdude = false;
  2794.                   }
  2795.                }
  2796.                else
  2797.                {
  2798.                   var hitdude = false;
  2799.                }
  2800.             }
  2801.             i++;
  2802.          }
  2803.          virtx = curx + _root.g._x;
  2804.          virty = cury + _root.g._y;
  2805.          if(!hitdude && !_root.starconnect)
  2806.          {
  2807.             if(_root.g.hitTest(virtx,virty,true) && !_root.cover.hitTest(virtx,virty,true))
  2808.             {
  2809.                if(_root.debug)
  2810.                {
  2811.                   t = r.attachMovie("exxon","test",cv);
  2812.                   t._x = curx;
  2813.                   t._y = cury;
  2814.                }
  2815.                curx += Xvel;
  2816.                cury += Yvel;
  2817.                cv++;
  2818.                Xvel *= 0.99;
  2819.                Yvel += 0.7;
  2820.                res[rescv][0] += 1;
  2821.             }
  2822.             else
  2823.             {
  2824.                if(_root.debug)
  2825.                {
  2826.                   t = r.attachMovie("blackdot","test",cv);
  2827.                   t._x = curx;
  2828.                   t._y = cury;
  2829.                }
  2830.                curx += Xvel;
  2831.                cury += Yvel;
  2832.                cv++;
  2833.                Xvel *= 0.99;
  2834.                Yvel += 0.7;
  2835.             }
  2836.          }
  2837.          f++;
  2838.       }
  2839.       rot -= 3;
  2840.       rescv += 1;
  2841.    }
  2842.    r.cacheAsBitmap = true;
  2843.    var min = 0;
  2844.    i = 0;
  2845.    while(i < res.length)
  2846.    {
  2847.       if(res[i][0] == 0)
  2848.       {
  2849.          if(res[i][1] > min)
  2850.          {
  2851.             min = res[i][1];
  2852.             var rotindex = i;
  2853.          }
  2854.       }
  2855.       i++;
  2856.    }
  2857.    if(rotindex == undefined)
  2858.    {
  2859.       var min = 0;
  2860.       i = 0;
  2861.       while(i < res.length)
  2862.       {
  2863.          if(res[i][1] > min)
  2864.          {
  2865.             min = res[i][1];
  2866.             rotindex = i;
  2867.          }
  2868.          i++;
  2869.       }
  2870.       trace("next best is: " + rotindex);
  2871.    }
  2872.    who.thinking._visible = false;
  2873.    return rotindex;
  2874. }
  2875. function turnTimer()
  2876. {
  2877.    if(_root.testingtime)
  2878.    {
  2879.       _root.turncv -= 1;
  2880.       if(_root.masterturn == "good")
  2881.       {
  2882.          _root.shownum0 = Math.floor(_root.turncv);
  2883.       }
  2884.       else
  2885.       {
  2886.          _root.shownum1 = Math.floor(_root.turncv);
  2887.       }
  2888.       if(_root.turncv == 0)
  2889.       {
  2890.          chargesound.stop();
  2891.          chargeloop.stop();
  2892.          _root.sel.buildingup = false;
  2893.          _root.sel.rdy = false;
  2894.          _root.sel.aiming = false;
  2895.          _root.sel.guts.gotoAndStop("rest");
  2896.          _root.testingtime = false;
  2897.          clearTel();
  2898.          clearInst();
  2899.          if(!_root.sel.drowned)
  2900.          {
  2901.             wrongsound.start();
  2902.          }
  2903.          else
  2904.          {
  2905.             splooshsound.start();
  2906.          }
  2907.          getTurn(true);
  2908.          _root.sel.guts.gotoAndStop("rest");
  2909.          _root.testingtime = false;
  2910.       }
  2911.    }
  2912. }
  2913. _root.flybysound = new Sound(this);
  2914. _root.flybysound.attachSound("flyby");
  2915. _root.walkiesound = new Sound(this);
  2916. _root.walkiesound.attachSound("walkietalkie");
  2917. _root.errorsound = new Sound(this);
  2918. _root.errorsound.attachSound("error");
  2919. _root.fanfaresound = new Sound(this);
  2920. _root.fanfaresound.attachSound("fanfare");
  2921. _root.losesound = new Sound(this);
  2922. _root.losesound.attachSound("lose");
  2923. _root.switchsound = new Sound(this);
  2924. _root.switchsound.attachSound("bloop");
  2925. _root.selsound = new Sound(this);
  2926. _root.selsound.attachSound("bleep");
  2927. _root.airtotal = 0;
  2928. _root.projtype = 1;
  2929. lineweight = 10;
  2930. _root.debug = false;
  2931. initLvl(12307626,16711680,cavern,_root.fgid,_root.bgid);
  2932. var keyListener = new Object();
  2933. keyListener.onKeyDown = function()
  2934. {
  2935.    var num = Key.getCode();
  2936.    if(_root.readytoswitchweapons)
  2937.    {
  2938.       if(num == 54)
  2939.       {
  2940.          if(sel.myweaps[5] > 0 || sel.myweaps[5] == -1)
  2941.          {
  2942.             freshInst(3);
  2943.             clearTel();
  2944.             _root.projtype = 3;
  2945.             _root.sel.guts.gotoAndStop("aiming");
  2946.             _root.sel.guts.aimclip.freshMe();
  2947.          }
  2948.       }
  2949.       if(num == 53)
  2950.       {
  2951.          if(sel.myweaps[4] > 0 || sel.myweaps[4] == -1)
  2952.          {
  2953.             freshInst(5);
  2954.             _root.sel.guts.gotoAndStop("walkie");
  2955.             _root.sel.guts.walkie.freshMe();
  2956.             _root.sel.aimer._visible = false;
  2957.             panon = true;
  2958.             t = _root.attachMovie("teletubby","teletubby",999);
  2959.             t._x = 350;
  2960.             t._y = 225;
  2961.             t.cross._visible = false;
  2962.             t.strike._visible = true;
  2963.             t.strike.origscale = t.strike._xscale;
  2964.             _root.airstrike = true;
  2965.          }
  2966.       }
  2967.       if(num == 52)
  2968.       {
  2969.          if(sel.myweaps[3] > 0 || sel.myweaps[3] == -1)
  2970.          {
  2971.             freshInst(4);
  2972.             clearTel();
  2973.             flashIt();
  2974.             _root.projtype = 4;
  2975.             sel.aimer._visible = false;
  2976.             sel.bar._visible = false;
  2977.             sel.pointer._visible = false;
  2978.             _root.sel.guts.gotoAndStop("punchcharge");
  2979.             _root.sel.guts.punchcharge.freshMe();
  2980.          }
  2981.       }
  2982.       if(num == 50)
  2983.       {
  2984.          if(sel.myweaps[1] > 0 || sel.myweaps[1] == -1)
  2985.          {
  2986.             freshInst(3);
  2987.             clearTel();
  2988.             _root.projtype = 0;
  2989.             _root.sel.guts.gotoAndStop("aiming");
  2990.             _root.sel.guts.aimclip.freshMe();
  2991.          }
  2992.       }
  2993.       if(num == 49)
  2994.       {
  2995.          if(sel.myweaps[0] > 0 || sel.myweaps[0] == -1)
  2996.          {
  2997.             freshInst(3);
  2998.             clearTel();
  2999.             _root.projtype = 1;
  3000.             _root.sel.guts.gotoAndStop("aiming");
  3001.             _root.sel.guts.aimclip.freshMe();
  3002.             _root.sel.guts.aimclip.zook.gotoAndPlay(1);
  3003.          }
  3004.       }
  3005.       if(num == 51)
  3006.       {
  3007.          if(sel.myweaps[2] > 0 || sel.myweaps[2] == -1)
  3008.          {
  3009.             freshInst(5);
  3010.             clearInterval(_root.teltimer);
  3011.             _root.sel.guts.gotoAndStop("walkie");
  3012.             _root.sel.guts.walkie.freshMe();
  3013.             _root.sel.aimer._visible = false;
  3014.             panon = true;
  3015.             t = _root.attachMovie("teletubby","teletubby",999);
  3016.             t._x = 350;
  3017.             t._y = 225;
  3018.             t.cross._visible = true;
  3019.             t.strike._visible = false;
  3020.             _root.teleportation = true;
  3021.          }
  3022.       }
  3023.       if(_root.airstrike && num == 32)
  3024.       {
  3025.          clearInst();
  3026.          walkiesound.start();
  3027.          flybysound.start();
  3028.          d = 0;
  3029.          while(d < team0.length)
  3030.          {
  3031.             var w = eval("_root.dudes.good" + d);
  3032.             w.bar._visible = false;
  3033.             w.pointer._visible = false;
  3034.             d++;
  3035.          }
  3036.          d = 0;
  3037.          while(d < team1.length)
  3038.          {
  3039.             var w = eval("_root.dudes.bad" + d);
  3040.             w.bar._visible = false;
  3041.             w.pointer._visible = false;
  3042.             d++;
  3043.          }
  3044.          if(sel.myweaps[4] > 0)
  3045.          {
  3046.             sel.myweaps[4] -= 1;
  3047.          }
  3048.          _root.sel.buildingup = false;
  3049.          _root.sel.rdy = false;
  3050.          _root.sel.aiming = false;
  3051.          _root.waitforretreat = true;
  3052.          _root.sel.guts.gotoAndStop("rest");
  3053.          _root.testingtime = false;
  3054.          _root.airtotal = 0;
  3055.          i = 0;
  3056.          while(i < 4)
  3057.          {
  3058.             m = dudes.attachMovie("angry","strike" + i,dudes.getNextHighestDepth());
  3059.             _root.airtotal += 1;
  3060.             if(teletubby.strike._xscale == teletubby.strike.origscale)
  3061.             {
  3062.                m._x = 350 - dudes._x + 75 * i + 300;
  3063.                m._y = -700 + 55 * i;
  3064.                m.Xvel = -10;
  3065.             }
  3066.             else
  3067.             {
  3068.                m._x = 350 - dudes._x - 75 * i - 300;
  3069.                m._y = -700 - 55 * i;
  3070.                m.Xvel = 10;
  3071.             }
  3072.             m.Yvel = 0;
  3073.             m.cv = 0;
  3074.             m.ject = true;
  3075.             m.airstrike = true;
  3076.             m.onEnterFrame = function()
  3077.             {
  3078.                powerBall(this,who);
  3079.             };
  3080.             i++;
  3081.          }
  3082.          clearTel();
  3083.       }
  3084.       if(_root.airstrike && num == 37)
  3085.       {
  3086.          teletubby.strike._xscale = teletubby.strike.origscale;
  3087.       }
  3088.       if(_root.airstrike && num == 39)
  3089.       {
  3090.          teletubby.strike._xscale = - teletubby.strike.origscale;
  3091.       }
  3092.       if(_root.teleportation && num == 32)
  3093.       {
  3094.          clearInst();
  3095.          flashIt();
  3096.          sel.guts.gotoAndStop("materialize");
  3097.          var who = _root.teletubby;
  3098.          who.virtx = who._x;
  3099.          who.virty = who._y;
  3100.          if(sel.myweaps[2] > 0)
  3101.          {
  3102.             sel.myweaps[2] -= 1;
  3103.          }
  3104.          if(!(_root.g.hitTest(who.virtx,who.virty,true) && !_root.cover.hitTest(who.virtx,who.virty,true)))
  3105.          {
  3106.             _root.sel._x = _root.teletubby._x - dudes._x;
  3107.             _root.sel._y = _root.teletubby._y - dudes._y;
  3108.             panon = false;
  3109.             _root.teletubby._visible = false;
  3110.             _root.teletimer = 0;
  3111.             clearInterval(_root.teltimer);
  3112.             _root.teltimer = setInterval(chkTel,100);
  3113.          }
  3114.       }
  3115.    }
  3116. };
  3117. Key.addListener(keyListener);
  3118. splooshsound = new Sound(this);
  3119. splooshsound.attachSound("sploosh");
  3120. chargesound = new Sound(this);
  3121. chargesound.attachSound("chargefix.wav");
  3122. chargeloop = new Sound(this);
  3123. chargeloop.attachSound("chargetoploop.wav");
  3124. splodesound = new Sound(this);
  3125. splodesound.attachSound("splosion1.wav");
  3126. throwsound = new Sound(this);
  3127. throwsound.attachSound("throw.wav");
  3128. powersound = new Sound(this);
  3129. powersound.attachSound("powerup");
  3130. tinksound = new Sound(this);
  3131. tinksound.attachSound("tink");
  3132. jumpsound = new Sound(this);
  3133. jumpsound.attachSound("varoop");
  3134. wrongsound = new Sound(this);
  3135. wrongsound.attachSound("wrong");
  3136. freshInst(0);
  3137. _root.onEnterFrame = function()
  3138. {
  3139.    if(!_root.waitforretreat)
  3140.    {
  3141.       controls();
  3142.    }
  3143.    if(g._y < -120)
  3144.    {
  3145.       g._y = -120;
  3146.    }
  3147.    if(g._y > 500)
  3148.    {
  3149.       g._y = 500;
  3150.    }
  3151.    if(g._x > -120)
  3152.    {
  3153.       g._x = -120;
  3154.    }
  3155.    if(g._x < -2120)
  3156.    {
  3157.       g._x = -2120;
  3158.    }
  3159.    alignAll();
  3160.    turnTimer();
  3161. };
  3162.